Customizable Section Name
This commit is contained in:
parent
a80f7247c2
commit
8ffb95d479
@ -58,6 +58,7 @@
|
||||
INPUT_REPOSITORY='<REPOSITORY SLUG>'
|
||||
INPUT_COMMIT_MESSAGE='<COMMIT MESSAGE>'
|
||||
INPUT_SHOW_TITLE='True'
|
||||
INPUT_SECTION_NAME='wakacustom'
|
||||
INPUT_BLOCKS='->'
|
||||
INPUT_SHOW_TIME='True'
|
||||
INPUT_SHOW_TOTAL='True'
|
||||
|
@ -30,7 +30,7 @@ Alternatively, you can also fetch data from WakaTime compatible services like [W
|
||||
|
||||
A GitHub repository and a README file is required. We'll be making use of readme in the [profile repository][profile_readme]\*.
|
||||
|
||||
- Save the README file after copy-pasting the following special comments. Your dev-metics will show up in between.
|
||||
- Save the README file after copy-pasting the following special comments. Your dev-metics will show up in between. `waka` here can be replaced by any string as long as you set the `SECTION_NAME` environment variable [as per the Tweaks section](tweaks).
|
||||
|
||||
```md
|
||||
|
||||
@ -78,6 +78,7 @@ There are many flags that you can tweak to suit your taste!
|
||||
| ------------------ | -------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
||||
| `API_BASE_URL` | `https://wakatime.com/api` | `https://wakatime.com/api`, `https://wakapi.dev/api`, `https://hakatime.mtx-dev.xyz/api` | Integration with WakaTime compatible services like [Wakapi][wakapi] & [Hakatime][hakatime] are possible |
|
||||
| `REPOSITORY` | `<gh_username>/<gh_username>` | `<gh_username>/<repo_name>` | Waka-readme stats will appear on the provided repository |
|
||||
| `SECTION_NAME` | `waka` | `any string` | The generator will look for this section to fill up the readme. |
|
||||
| `COMMIT_MESSAGE` | `Updated waka-readme graph with new metrics` | anything else! | Messaged used when committing updated stats |
|
||||
| `SHOW_TITLE` | `false` | `false`, `true` | Add title to waka-readme stats blob |
|
||||
| `BLOCKS` | `░▒▓█` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, you can be creative! | Ascii art used to build stats graph |
|
||||
|
@ -34,6 +34,11 @@ inputs:
|
||||
default: "false"
|
||||
required: false
|
||||
|
||||
SECTION_NAME:
|
||||
description: "Section name for data to appear in readme"
|
||||
required: false
|
||||
default: "waka"
|
||||
|
||||
BLOCKS:
|
||||
description: "Add the progress blocks of your choice"
|
||||
default: "░▒▓█"
|
||||
|
15
main.py
15
main.py
@ -66,10 +66,16 @@ class WakaConstants:
|
||||
"""
|
||||
prefix_length: int = 16
|
||||
graph_length: int = 25
|
||||
start_comment: str = '<!--START_SECTION:waka-->'
|
||||
end_comment: str = '<!--END_SECTION:waka-->'
|
||||
section: str = os.getenv("INPUT_SECTION_NAME", "waka")
|
||||
start_comment: str = f'<!--START_SECTION:{section}-->'
|
||||
end_comment: str = f'<!--END_SECTION:{section}-->'
|
||||
waka_block_pattern: str = f'{start_comment}[\\s\\S]+{end_comment}'
|
||||
|
||||
def validate_constants(self) -> bool:
|
||||
if not (self.section):
|
||||
logger.error('Invalid section name input, refer README')
|
||||
return False
|
||||
|
||||
|
||||
class WakaInput:
|
||||
"""
|
||||
@ -336,7 +342,7 @@ def churn(old_readme: str, /) -> str | None:
|
||||
if not (waka_stats := fetch_stats()):
|
||||
logger.error('Unable to fetch data, please rerun workflow')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# processing content
|
||||
generated_content = prep_content(waka_stats)
|
||||
print(generated_content, '\n', sep='')
|
||||
@ -350,6 +356,7 @@ def churn(old_readme: str, /) -> str | None:
|
||||
# to avoid accidentally writing back to Github
|
||||
# when developing and testing WakaReadme
|
||||
return None
|
||||
|
||||
return None if new_readme == old_readme else new_readme
|
||||
|
||||
|
||||
@ -411,7 +418,7 @@ if __name__ == '__main__':
|
||||
logger.debug('Initialize WakaReadme')
|
||||
wk_c = WakaConstants()
|
||||
wk_i = WakaInput()
|
||||
if not wk_i.validate_input():
|
||||
if not (wk_i.validate_input() or wk_i.validate_constants()):
|
||||
logger.error('Environment variables are misconfigured')
|
||||
sys.exit(1)
|
||||
logger.debug('Input validation complete')
|
||||
|
Loading…
x
Reference in New Issue
Block a user