diff --git a/.env.example b/.env.example index f46d8271..fbe5df6c 100644 --- a/.env.example +++ b/.env.example @@ -9,6 +9,8 @@ INPUT_SHOW_EDITORS=True INPUT_SHOW_OS=True INPUT_SHOW_LANGUAGE=True INPUT_SYMBOL_VERSION=1 +INPUT_SYMBOL_STYLE=█░ +INPUT_CODE_BLOCK_LANGUAGE=text INPUT_SHOW_LINES_OF_CODE=True INPUT_SHOW_LOC_CHART=True INPUT_SHOW_PROFILE_VIEWS=True diff --git a/README.md b/README.md index 31da994a..28746522 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,10 @@ CSS 2 repos █░░░░░░░░░░░░░░░░ | 2 | ⣿ | ⣀ | | 3 | ⬛ | ⬜ | +`SYMBOL_STYLE` flag can be set to `"▰▱"` (just an example) to change the style of progress bar (by default is empty). If the length of the string is not 2, the default symbol version will be used. + +`CODE_BLOCK_LANGUAGE` flag can be set to `"python"` (just an example) to change the language of code blocks (by default is `"text"`). Here is a [list](https://github.com/jincheng9/markdown_supported_languages) of the language code blocks supported by github + `DEBUG_LOGGING` flag can be set to increase action output verbosity, by default equals internal runner debug property **Timeline** @@ -424,6 +428,8 @@ Contributions are welcome! ♥! Please share any features, and add unit tests! U - [Wyatt Walsh](https://www.github.com/wyattowalsh) - [Nithin Balaji](https://github.com/thenithinbalaji) + + - [Caupolicán Ré](https://github.com/caupolicanre) diff --git a/action.yml b/action.yml index 8a413d84..a5ce42a6 100644 --- a/action.yml +++ b/action.yml @@ -1,156 +1,166 @@ -name: 'Profile Readme Development Stats' -author: Anmol Pratap Singh -description: 'Are you an early 🐤 or a night 🦉? When are you most productive during the day? Let''s check out in your readme!' - -inputs: - GH_TOKEN: - description: 'GitHub access token with Repo scope' - required: true - default: ${{ github.token }} - - WAKATIME_API_KEY: - description: 'Your Wakatime API Key' - required: true - - SECTION_NAME: - description: 'Name used in readme to scope the updated section' - required: false - default: "waka" - - PULL_BRANCH_NAME: - required: false - description: "The branch to get the readme from" - default: "" - - PUSH_BRANCH_NAME: - required: false - description: "The branch to update the readme in" - default: "" - - SHOW_OS: - required: false - description: 'Show the list of OS Worked on In dev metrics' - default: "True" - - SHOW_PROJECTS: - required: false - description: 'Show the list of projects worked on in dev metrics' - default: "True" - - SHOW_EDITORS: - required: false - description: 'Show the Editors used in dev metrics' - default: "True" - - SHOW_TIMEZONE: - required: false - description: 'Show the time zone in the dev metrics' - default: "True" - - SHOW_COMMIT: - required: false - description: "Shows the number of commit graph in the dev metrics" - default: "True" - - SHOW_LANGUAGE: - required: false - description: "Show the Coding language used in dev metrics" - default: "True" - - SHOW_LINES_OF_CODE: - required: false - description: "Show the Total Lines of code written Badge till date" - default: "False" - - SHOW_LANGUAGE_PER_REPO: - required: false - description: "Show language or framework used across different repository" - default: "True" - - SHOW_LOC_CHART: - required: false - description: "" - default: "True" - - SHOW_DAYS_OF_WEEK: - required: false - description: "show day of week you are most productive" - default: "True" - - SHOW_PROFILE_VIEWS: - required: false - description: "Shows the current profile views" - default: "True" - - SHOW_SHORT_INFO: - required: false - description: "Shows the short facts" - default: "True" - - SHOW_UPDATED_DATE: - required: false - description: "Show updated date" - default: "True" - - SHOW_TOTAL_CODE_TIME: - required: false - description: "Show Total Time you have coded" - default: "True" - - COMMIT_BY_ME: - required: false - description: "Git commit with your own name and email" - default: "False" - - COMMIT_MESSAGE: - required: false - description: "Git commit message" - default: "Updated with Dev Metrics" - - COMMIT_USERNAME: - required: false - description: "Git commit custom username" - default: "" - - COMMIT_EMAIL: - required: false - description: "Git commit custom email" - default: "" - - COMMIT_SINGLE: - required: false - description: "Erase commit history on each commit" - default: "False" - - LOCALE: - required: false - description: "Show stats in your own language" - default: "en" - - UPDATED_DATE_FORMAT: - required: false - description: "Updated date format" - default: "%d/%m/%Y %H:%M:%S" - - IGNORED_REPOS: - required: false - description: "Repos you don't want to be counted" - default: "" - - SYMBOL_VERSION: - required: false - description: "Version of the symbol block and empty of the progress bar" - default: "1" - - DEBUG_LOGGING: - required: false - description: "Whether to enable action debug logging" - default: ${{ runner.debug }} - -runs: - using: 'docker' - image: 'docker://wakareadmestats/waka-readme-stats:master' - -branding: - icon: 'activity' - color: 'orange' +name: 'Profile Readme Development Stats' +author: Anmol Pratap Singh +description: 'Are you an early 🐤 or a night 🦉? When are you most productive during the day? Let''s check out in your readme!' + +inputs: + GH_TOKEN: + description: 'GitHub access token with Repo scope' + required: true + default: ${{ github.token }} + + WAKATIME_API_KEY: + description: 'Your Wakatime API Key' + required: true + + SECTION_NAME: + description: 'Name used in readme to scope the updated section' + required: false + default: "waka" + + PULL_BRANCH_NAME: + required: false + description: "The branch to get the readme from" + default: "" + + PUSH_BRANCH_NAME: + required: false + description: "The branch to update the readme in" + default: "" + + SHOW_OS: + required: false + description: 'Show the list of OS Worked on In dev metrics' + default: "True" + + SHOW_PROJECTS: + required: false + description: 'Show the list of projects worked on in dev metrics' + default: "True" + + SHOW_EDITORS: + required: false + description: 'Show the Editors used in dev metrics' + default: "True" + + SHOW_TIMEZONE: + required: false + description: 'Show the time zone in the dev metrics' + default: "True" + + SHOW_COMMIT: + required: false + description: "Shows the number of commit graph in the dev metrics" + default: "True" + + SHOW_LANGUAGE: + required: false + description: "Show the Coding language used in dev metrics" + default: "True" + + SHOW_LINES_OF_CODE: + required: false + description: "Show the Total Lines of code written Badge till date" + default: "False" + + SHOW_LANGUAGE_PER_REPO: + required: false + description: "Show language or framework used across different repository" + default: "True" + + SHOW_LOC_CHART: + required: false + description: "" + default: "True" + + SHOW_DAYS_OF_WEEK: + required: false + description: "show day of week you are most productive" + default: "True" + + SHOW_PROFILE_VIEWS: + required: false + description: "Shows the current profile views" + default: "True" + + SHOW_SHORT_INFO: + required: false + description: "Shows the short facts" + default: "True" + + SHOW_UPDATED_DATE: + required: false + description: "Show updated date" + default: "True" + + SHOW_TOTAL_CODE_TIME: + required: false + description: "Show Total Time you have coded" + default: "True" + + COMMIT_BY_ME: + required: false + description: "Git commit with your own name and email" + default: "False" + + COMMIT_MESSAGE: + required: false + description: "Git commit message" + default: "Updated with Dev Metrics" + + COMMIT_USERNAME: + required: false + description: "Git commit custom username" + default: "" + + COMMIT_EMAIL: + required: false + description: "Git commit custom email" + default: "" + + COMMIT_SINGLE: + required: false + description: "Erase commit history on each commit" + default: "False" + + LOCALE: + required: false + description: "Show stats in your own language" + default: "en" + + UPDATED_DATE_FORMAT: + required: false + description: "Updated date format" + default: "%d/%m/%Y %H:%M:%S" + + IGNORED_REPOS: + required: false + description: "Repos you don't want to be counted" + default: "" + + SYMBOL_VERSION: + required: false + description: "Version of the symbol block and empty of the progress bar" + default: "1" + + SYMBOL_STYLE: + required: false + description: "Style of the symbol block and empty of the progress bar" + default: "" + + CODE_BLOCK_LANGUAGE: + required: false + description: "Language of the code block" + default: "text" + + DEBUG_LOGGING: + required: false + description: "Whether to enable action debug logging" + default: ${{ runner.debug }} + +runs: + using: 'docker' + image: 'docker://wakareadmestats/waka-readme-stats:master' + +branding: + icon: 'activity' + color: 'orange' diff --git a/sources/graphics_list_formatter.py b/sources/graphics_list_formatter.py index d7c0a28b..b416dad9 100644 --- a/sources/graphics_list_formatter.py +++ b/sources/graphics_list_formatter.py @@ -42,7 +42,10 @@ def make_graph(percent: float): :param percent: Completion percent of the progress bar. :return: The string progress bar representation. """ - done_block, empty_block = Symbol.get_symbols(EM.SYMBOL_VERSION) + if len(EM.SYMBOL_STYLE) == 2: + done_block, empty_block = EM.SYMBOL_STYLE[0], EM.SYMBOL_STYLE[1] + else: + done_block, empty_block = Symbol.get_symbols(EM.SYMBOL_VERSION) percent_quart = round(percent / 4) return f"{done_block * percent_quart}{empty_block * (25 - percent_quart)}" @@ -108,14 +111,14 @@ async def make_commit_day_time_list(time_zone: str, repositories: Dict, commit_d dt_texts = [f"{day_time} commits" for day_time in day_times] dt_percents = [0 if sum_day == 0 else round((day_time / sum_day) * 100, 2) for day_time in day_times] title = FM.t("I am an Early") if sum(day_times[0:2]) >= sum(day_times[2:4]) else FM.t("I am a Night") - stats += f"**{title}** \n\n```text\n{make_list(names=dt_names, texts=dt_texts, percents=dt_percents, top_num=7, sort=False)}\n```\n" + stats += f"**{title}** \n\n```{EM.CODE_BLOCK_LANGUAGE}\n{make_list(names=dt_names, texts=dt_texts, percents=dt_percents, top_num=7, sort=False)}\n```\n" if EM.SHOW_DAYS_OF_WEEK: wd_names = [FM.t(week_day) for week_day in WEEK_DAY_NAMES] wd_texts = [f"{week_day} commits" for week_day in week_days] wd_percents = [0 if sum_week == 0 else round((week_day / sum_week) * 100, 2) for week_day in week_days] title = FM.t("I am Most Productive on") % wd_names[wd_percents.index(max(wd_percents))] - stats += f"📅 **{title}** \n\n```text\n{make_list(names=wd_names, texts=wd_texts, percents=wd_percents, top_num=7, sort=False)}\n```\n" + stats += f"📅 **{title}** \n\n```{EM.CODE_BLOCK_LANGUAGE}\n{make_list(names=wd_names, texts=wd_texts, percents=wd_percents, top_num=7, sort=False)}\n```\n" return stats @@ -140,4 +143,4 @@ def make_language_per_repo_list(repositories: Dict) -> str: top_language = max(list(language_count.keys()), key=lambda x: language_count[x]["count"]) title = f"**{FM.t('I Mostly Code in') % top_language}** \n\n" if len(repos_with_language) > 0 else "" - return f"{title}```text\n{make_list(names=names, texts=texts, percents=percents)}\n```\n\n" + return f"{title}```{EM.CODE_BLOCK_LANGUAGE}\n{make_list(names=names, texts=texts, percents=percents)}\n```\n\n" diff --git a/sources/main.py b/sources/main.py index 7368c9b0..0bb8ffaa 100644 --- a/sources/main.py +++ b/sources/main.py @@ -40,7 +40,7 @@ async def get_waka_time_stats(repositories: Dict, commit_dates: Dict) -> str: if EM.SHOW_TIMEZONE or EM.SHOW_LANGUAGE or EM.SHOW_EDITORS or EM.SHOW_PROJECTS or EM.SHOW_OS: no_activity = FM.t("No Activity Tracked This Week") - stats += f"📊 **{FM.t('This Week I Spend My Time On')}** \n\n```text\n" + stats += f"📊 **{FM.t('This Week I Spend My Time On')}** \n\n```{EM.CODE_BLOCK_LANGUAGE}\n" if EM.SHOW_TIMEZONE: DBM.i("Adding user timezone info...") diff --git a/sources/manager_environment.py b/sources/manager_environment.py index 33bbee44..472610b5 100644 --- a/sources/manager_environment.py +++ b/sources/manager_environment.py @@ -45,6 +45,8 @@ class EnvironmentManager: UPDATED_DATE_FORMAT = getenv("INPUT_UPDATED_DATE_FORMAT", "%d/%m/%Y %H:%M:%S") IGNORED_REPOS = getenv("INPUT_IGNORED_REPOS", "").replace(" ", "").split(",") SYMBOL_VERSION = int(getenv("INPUT_SYMBOL_VERSION")) + SYMBOL_STYLE: str = getenv("INPUT_SYMBOL_STYLE", "") + CODE_BLOCK_LANGUAGE: str = getenv("INPUT_CODE_BLOCK_LANGUAGE", "text") DEBUG_LOGGING = getenv("INPUT_DEBUG_LOGGING", "0").lower() in _TRUTHY DEBUG_RUN = getenv("DEBUG_RUN", "False").lower() in _TRUTHY