Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Add custom symbol style and custom code block language #491

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ad5c77d
Add new symbol version
caupolicanre Dec 3, 2023
e85eefe
Add new symbols for VERSION_4
caupolicanre Dec 3, 2023
3a88e90
Add symbol style option to .env.example and
caupolicanre Dec 3, 2023
f3d179d
Refactor progress bar symbol handling
caupolicanre Dec 3, 2023
ad6d3f4
Remove default symbol style in action.yml
caupolicanre Dec 3, 2023
937d0d3
Remove unused symbol style
caupolicanre Dec 3, 2023
671b673
Add SYMBOL_STYLE flag to change progress bar style
caupolicanre Dec 3, 2023
9618a41
small change in SYMBOL_STYLE env variable README
caupolicanre Dec 3, 2023
4384df8
Update action.yml and .env.example files with CODE_BLOCK_LANGUAGE env…
caupolicanre Dec 3, 2023
bed1496
Refactor code to use code block language in stats
caupolicanre Dec 4, 2023
3a6d86a
Update README.md with code block language flag
caupolicanre Dec 4, 2023
42d825e
Update action.yml to test actions behavior
caupolicanre Dec 4, 2023
c37ff55
Small change to test action
caupolicanre Dec 4, 2023
32bad51
Testing action with composite
caupolicanre Dec 4, 2023
fd0a05b
Update pip installation and add conditional check
caupolicanre Dec 4, 2023
50c6666
Update run command in action.yml
caupolicanre Dec 4, 2023
44acf0a
Update action.yml to install dependencies and run
caupolicanre Dec 4, 2023
4d9360d
Update action.yml to use Docker for running the
caupolicanre Dec 4, 2023
8b4f18f
Fix Dockerfile casing
caupolicanre Dec 4, 2023
131f17f
Fix symbol style check in make_graph function
caupolicanre Dec 4, 2023
98b3702
Fix symbol style assignment in make_graph function
caupolicanre Dec 4, 2023
437c0f1
Fix progress bar symbol style bug
caupolicanre Dec 4, 2023
3f4bd8c
Remove commented out code and update runs section
caupolicanre Dec 4, 2023
728027f
Merge pull request #1 from caupolicanre/customize_text_field
caupolicanre Dec 4, 2023
025f504
Update action.yml
caupolicanre Dec 4, 2023
b11cac2
Rollback to upstream original 'action.yml' file
caupolicanre Dec 4, 2023
2ea7da6
Add new env variables to action.yml
caupolicanre Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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)



Expand Down
322 changes: 166 additions & 156 deletions action.yml
pseusys marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 7 additions & 4 deletions sources/graphics_list_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"

Expand Down Expand Up @@ -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

Expand All @@ -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"
2 changes: 1 addition & 1 deletion sources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
Loading