Skip to content

Commit

Permalink
feat: adds new flag INPUT_IGNORED_LANGUAGES
Browse files Browse the repository at this point in the history
  • Loading branch information
yozachar committed Oct 21, 2023
1 parent b489247 commit a91557b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ INPUT_SHOW_TIME=
INPUT_SHOW_TOTAL=
INPUT_SHOW_MASKED_TIME=
INPUT_STOP_AT_OTHER=
INPUT_IGNORED_LANGUAGES=
# commit
INPUT_COMMIT_MESSAGE=
INPUT_TARGET_BRANCH=
Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ INPUT_TIME_RANGE=last_7_days
INPUT_SHOW_MASKED_TIME=false
INPUT_LANG_COUNT=0
INPUT_STOP_AT_OTHER=true
INPUT_IGNORED_LANGUAGES=
```

**NEVER commit this `.env` file!**
Expand All @@ -32,10 +33,8 @@ INPUT_STOP_AT_OTHER=true
> Replace `podman` with `docker` everywhere, if you're using the latter.
```sh
# Build
$ podman-compose -p waka-readme -f ./docker-compose.yml up -d
# Logs
$ podman logs WakaReadmeDev
# Build and watch logs
$ podman-compose -p waka-readme -f ./docker-compose.yml up
# Cleanup
$ podman-compose -p waka-readme -f ./docker-compose.yml down
```
Expand Down
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ A GitHub repository and a `README.md` file is required. We'll be making use of r
name: WakaReadme DevMetrics
runs-on: ubuntu-latest
steps:
- uses: athul/waka-readme@master
- uses: athul/waka-readme@master # this action name
with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
```
Expand All @@ -113,19 +113,19 @@ There are many flags that you can modify as you see fit.

### Content Tweaks

| Environment flag | Options (`Default`, `Other`, ...) | Description |
| ------------------ | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `SHOW_TITLE` | `false`, `true` | Add title to waka-readme stats blob |
| `SECTION_NAME` | `waka`, any alphanumeric string | The generator will look for section name to fill up the readme. |
| `BLOCKS` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, `=>`, you can be creative | Ascii art used to build stats graph |
| `CODE_LANG` | `txt`, `python` `ruby` `json` , you can use other languages also | Language syntax based highlighted text |
| `TIME_RANGE` | `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time` | String representing a dispensation from which stats are aggregated |
| `LANG_COUNT` | `5`, any plausible number | Number of languages to be displayed |
| `SHOW_TIME` | `true`, `false` | Displays the amount of time spent for each language |
| `SHOW_TOTAL` | `false`, `true` | Show total coding time |
| `SHOW_MASKED_TIME` | `false`, `true` | Adds total coding time including unclassified languages (overrides: `SHOW_TOTAL`) |
| `STOP_AT_OTHER` | `false`, `true` | Stop when language marked as `Other` is retrieved (overrides: `LANG_COUNT`) |
| `IGNORE_LANGUAGES` | `binary,json` | Hide any language you wouldn't like to show in your stats |
| Environment flag | Options (`Default`, `Other`, ...) | Description |
| ------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `SHOW_TITLE` | `false`, `true` | Add title to waka-readme stats blob |
| `SECTION_NAME` | `waka`, any alphanumeric string | The generator will look for section name to fill up the readme. |
| `BLOCKS` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, `=>`, you can be creative | Ascii art used to build stats graph |
| `CODE_LANG` | `txt`, `python` `ruby` `json` , you can use other languages also | Language syntax based highlighted text |
| `TIME_RANGE` | `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time` | String representing a dispensation from which stats are aggregated |
| `LANG_COUNT` | `5`, any plausible number | Number of languages to be displayed |
| `SHOW_TIME` | `true`, `false` | Displays the amount of time spent for each language |
| `SHOW_TOTAL` | `false`, `true` | Show total coding time |
| `SHOW_MASKED_TIME` | `false`, `true` | Adds total coding time including unclassified languages (overrides: `SHOW_TOTAL`) |
| `STOP_AT_OTHER` | `false`, `true` | Stop when language marked as `Other` is retrieved (overrides: `LANG_COUNT`) |
| `IGNORED_LANGUAGES` | <code> </code>, `Binary YAML JSON TOML` | Hide languages from your stats |

### Commit Tweaks

Expand Down Expand Up @@ -160,7 +160,8 @@ jobs:
name: WakaReadme DevMetrics
runs-on: ubuntu-latest
steps:
- uses: athul/waka-readme@master
# this action name
- uses: athul/waka-readme@master # do NOT replace with anything else
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # optional if on profile readme
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }} # required
Expand Down Expand Up @@ -215,7 +216,7 @@ Other 47 hrs 58 mins >------------------------ 03.05 %
- If you are using `GH_TOKEN`, make sure set the [fine grained token](https://github.com/settings/tokens?type=beta) scope to repository contents with `read-and-write` access. See [#141 (comment)](https://github.com/athul/waka-readme/issues/141#issuecomment-1679831949).
- `WAKATIME_API_KEY` is a **required** secret. All other environment variables are optional.
- The above example does NOT show proper default values, refer [#Tweaks](#tweaks) for the same.
- `IGNORE_LANGUAGES` is recommended for those who uses [.NET](https://dotnet.microsoft.com/) as while debugging WakaTime thinks you're using Binary.
- `IGNORED_LANGUAGES` is suggested for [.NET](https://dotnet.microsoft.com) users, as WakaTime assumes you're working with `Binary`, while debugging.

## Why only the language stats (and not other data) from the API?

Expand Down
13 changes: 2 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"""

# standard
from typing import List
from base64 import b64encode
from dataclasses import dataclass
from datetime import datetime
Expand Down Expand Up @@ -319,32 +318,24 @@ def prep_content(stats: dict[str, Any], /):
ignored_languages = set[str](igl.lower() for igl in wk_i.ignored_languages.strip().split())
for idx, lang in enumerate(lang_info):
lang_name = str(lang["name"])
# >>> add languages to filter here <<<
# if lang_name in {...}: continue
if (lang_name := str(lang["name"])).lower() in ignored_languages:
if ignored_languages and lang_name.lower() in ignored_languages:
continue
lang_time = str(lang["text"]) if wk_i.show_time else ""
lang_ratio = float(lang["percent"])

if lang_name.lower() in ignore_languages:
continue

lang_bar = make_graph(wk_i.block_style, lang_ratio, wk_i.graph_length, lang_name)
contents += (
f"{lang_name.ljust(pad_len)} "
+ f"{lang_time: <16}{lang_bar} "
+ f"{lang_ratio:.2f}".zfill(5)
+ " %\n"
)
if wk_i.language_count == -1:
if language_count == -1:
continue
if stop_at_other and (lang_name == "Other"):
break
if idx + 1 >= language_count > 0: # idx starts at 0
break

idx += 1

logger.debug("Contents were made\n")
return contents.rstrip("\n")

Expand Down

0 comments on commit a91557b

Please sign in to comment.