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 38a31a9c..b82220f9 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,12 @@ The `SYMBOL_VERSION` flag can be set for the symbol for the progress bar (defaul | 2 | ⣿ | ⣀ | | 3 | ⬛ | ⬜ | +The `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. + +The `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. + The `DEBUG_LOGGING` flag can be set to increase the GitHub Action's output verbosity, The default is the internal runner's debug property. + The `BADGE_STYLE` flag defines the style for the generated badges and can be set to `flat`, `flat-square`, `plastic`, `for-the-badge`, or `social`. | Badge Style | Preview | | ----------------- | ------------------------------------------------------------------------------------------------- | @@ -459,6 +464,8 @@ Please share any features, and add unit tests! Use the pull request and issue sy - [Wyatt Walsh](https://www.github.com/wyattowalsh) - [Nithin Balaji](https://github.com/thenithinbalaji) + +- [Caupolicán Ré](https://github.com/caupolicanre) - [John Cortés](https://github.com/johncortes117) diff --git a/action.yml b/action.yml index 50a1d7aa..f56e6380 100644 --- a/action.yml +++ b/action.yml @@ -1,177 +1,188 @@ -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? 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 - - WAKATIME_API_URL: - description: 'Your Wakatime API URL' - required: false - default: "https://wakatime.com/api/v1/" - - 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: "" - - MAX_REPOS: - required: false - description: "Maximum number of GitHub repositories to fetch (0 = unlimited)" - default: "0" - - MAX_CAP: - required: false - description: "(Deprecated) Alias for MAX_REPOS" - default: "0" - - SYMBOL_VERSION: - required: false - description: "Version of the symbol block and empty of the progress bar" - default: "1" - - BADGE_STYLE: - required: false - description: "Style for the badge maker (flat, flat-square, plastic, for-the-badge, social)" - default: "flat" - - 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? 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 + + WAKATIME_API_URL: + description: 'Your Wakatime API URL' + required: false + default: "https://wakatime.com/api/v1/" + + 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: "" + + MAX_REPOS: + required: false + description: "Maximum number of GitHub repositories to fetch (0 = unlimited)" + default: "0" + + MAX_CAP: + required: false + description: "(Deprecated) Alias for MAX_REPOS" + default: "0" + + 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" + + BADGE_STYLE: + required: false + description: "Style for the badge maker (flat, flat-square, plastic, for-the-badge, social)" + default: "flat" + + 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 8a8deb09..de4ca4ba 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 @@ -143,4 +146,4 @@ def make_language_per_repo_list(repositories: Dict) -> str: title = f"**{FM.t('I Mostly Code in') % top_language}** \n\n" else: title = "" - 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 ac715b18..d4dea4ba 100644 --- a/sources/main.py +++ b/sources/main.py @@ -45,7 +45,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 c56e6970..963943af 100644 --- a/sources/manager_environment.py +++ b/sources/manager_environment.py @@ -67,6 +67,8 @@ class EnvironmentManager: if MAX_REPOS < 0: MAX_REPOS = 0 SYMBOL_VERSION = int(getenv("INPUT_SYMBOL_VERSION", "1")) + SYMBOL_STYLE: str = getenv("INPUT_SYMBOL_STYLE", "") + CODE_BLOCK_LANGUAGE: str = getenv("INPUT_CODE_BLOCK_LANGUAGE", "text") BADGE_STYLE = getenv("BADGE_STYLE", "flat") DEBUG_LOGGING = getenv("INPUT_DEBUG_LOGGING", "0").lower() in _TRUTHY