Skip to content

Commit b09d199

Browse files
committed
2 parents 4ca884e + 97d3af7 commit b09d199

File tree

9 files changed

+199
-32
lines changed

9 files changed

+199
-32
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# Docs tmp files
107+
docs/tags_list.txt

docs/conf.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,62 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'GitHub Activity'
21-
copyright = '2020, Chris Holdgraf'
22-
author = 'Chris Holdgraf'
20+
project = "GitHub Activity"
21+
copyright = "2020, Chris Holdgraf"
22+
author = "Chris Holdgraf"
2323

2424

2525
# -- General configuration ---------------------------------------------------
2626

2727
# Add any Sphinx extension module names here, as strings. They can be
2828
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929
# ones.
30-
extensions = [
31-
"myst_parser"
32-
]
30+
extensions = ["myst_parser"]
3331

3432
# Add any paths that contain templates here, relative to this directory.
35-
templates_path = ['_templates']
33+
templates_path = ["_templates"]
3634

3735
# List of patterns, relative to source directory, that match files and
3836
# directories to ignore when looking for source files.
3937
# This pattern also affects html_static_path and html_extra_path.
40-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
38+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4139

4240

4341
# -- Options for HTML output -------------------------------------------------
4442

4543
# The theme to use for HTML and HTML Help pages. See the documentation for
4644
# a list of builtin themes.
4745
#
48-
html_theme = 'sphinx_book_theme'
46+
html_theme = "sphinx_book_theme"
4947
html_theme_options = {"single_page": True}
5048

5149
# Add any paths that contain custom static files (such as style sheets) here,
5250
# relative to this directory. They are copied after the builtin static files,
5351
# so a file named "default.css" will overwrite the builtin "default.css".
54-
html_static_path = ['_static']
52+
html_static_path = ["_static"]
53+
54+
# Add a table of the supported PR types, tags, etc
55+
from github_activity.github_activity import TAGS_METADATA_BASE
56+
57+
table_content = []
58+
for key, vals in TAGS_METADATA_BASE.items():
59+
cont = [
60+
key,
61+
" ".join(vals["tags"]),
62+
" ".join(vals["pre"]),
63+
f'"{vals["description"]}"',
64+
]
65+
table_content.append(", ".join(cont))
66+
67+
table_content = "\n".join(table_content)
68+
table_template = f"""
69+
```{{csv-table}} List of PR types
70+
:header: PR type, Tags, Prefix, Description
71+
72+
{table_content}
73+
```
74+
"""
75+
76+
from pathlib import Path
77+
78+
Path("./tags_list.txt").write_text(table_template)

docs/index.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The easiest way to install this package is to do so directly from GitHub with `p
2222
pip install git+https://github.com/choldgraf/github-activity
2323
```
2424

25-
## Usage
25+
## Generate a markdown changelog
2626

2727
The easiest way to use `github-activity` to generate activity markdown is to use
2828
the command-line interface. It takes the following form:
@@ -50,6 +50,28 @@ github-activity jupyter/notebook -s 6.0.0 -u 6.0.1 -o sample_notebook_activity.m
5050

5151
You can find the [resulting markdown here](sample_notebook_activity).
5252

53+
### Splitting PRs by tags and prefixes
54+
55+
Often you wish to split your PRs into multiple categories so that they are easier
56+
to scan and parse. You may also *only* want to keep some PRs (e.g. features, or API
57+
changes) while excluding others from your changelog.
58+
59+
`github-activity` uses the GitHub tags as well as PR prefixes to automatically
60+
categorize each PR and display it in a section in your markdown. It roughly
61+
follows the [keepachangelog taxonomy of changes](https://keepachangelog.com/en/1.0.0/).
62+
63+
Below is a list of the supported PR types, as well as the tags / title prefixes
64+
that will be used to identify the right category.
65+
66+
```{include} tags_list.txt
67+
```
68+
69+
```{tip}
70+
You can choose to *remove* some types of PRs from your changelog by passing the
71+
`--tags` parameter in the CLI. This is a list of a subset of names taken from the
72+
left-most column above.
73+
```
74+
5375
### Using a GitHub API token
5476

5577
`github-activity` uses the GitHub API to pull information about a repository's activity.
@@ -89,4 +111,4 @@ contributor is anyone who has:
89111
* Commented on >= 2 issues that weren't theirs
90112
* Commented >= 6 times on any one issue
91113

92-
We'd love feedback on whether this is a good set of rules to use.
114+
We'd love feedback on whether this is a good set of rules to use.

github_activity/github_activity.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,41 @@
1414

1515
# The tags and description to use in creating subsets of PRs
1616
TAGS_METADATA_BASE = {
17+
"new": {
18+
"tags": ["feature", "new"],
19+
"pre": ["NEW", "FEAT", "FEATURE"],
20+
"description": "New features added",
21+
},
1722
"enhancement": {
18-
"tags": ["enhancement", "feature", "enhancements"],
23+
"tags": ["enhancement", "enhancements"],
24+
"pre": ["NEW", "ENH", "ENHANCEMENT", "IMPROVE"],
1925
"description": "Enhancements made",
2026
},
21-
"bug": {"tags": ["bug", "bugfix", "bugs"], "description": "Bugs fixed",},
27+
"bug": {
28+
"tags": ["bug", "bugfix", "bugs"],
29+
"pre": ["FIX", "BUG"],
30+
"description": "Bugs fixed",
31+
},
2232
"maintenance": {
2333
"tags": ["maintenance", "maint"],
34+
"pre": ["MAINT", "MNT"],
2435
"description": "Maintenance and upkeep improvements",
2536
},
2637
"documentation": {
2738
"tags": ["documentation", "docs", "doc"],
39+
"pre": ["DOC", "DOCS"],
2840
"description": "Documentation improvements",
2941
},
30-
"api_change": {"tags": ["api-change", "apichange"], "description": "API Changes",},
42+
"api_change": {
43+
"tags": ["api-change", "apichange"],
44+
"pre": ["BREAK", "BREAKING", "BRK", "UPGRADE"],
45+
"description": "API and Breaking Changes",
46+
},
47+
"deprecate": {
48+
"tags": ["deprecation", "deprecate"],
49+
"pre": ["DEPRECATE", "DEPRECATION", "DEP"],
50+
"description": "Deprecated features",
51+
},
3152
}
3253

3354

@@ -273,9 +294,16 @@ def generate_activity_md(
273294

274295
# Separate out items by their tag types
275296
for kind, kindmeta in tags_metadata.items():
297+
# First find the PRs based on tag
276298
mask = closed_prs["labels"].map(
277299
lambda a: any(ii in jj for ii in kindmeta["tags"] for jj in a)
278300
)
301+
# Now find PRs based on prefix
302+
mask_pre = closed_prs["title"].map(
303+
lambda title: any(f"{ipre}:" in title for ipre in kindmeta["pre"])
304+
)
305+
mask = mask | mask_pre
306+
279307
kindmeta["data"] = closed_prs.loc[mask]
280308
kindmeta["mask"] = mask
281309

github_activity/tags.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
api_change:
2+
description: API and Breaking Changes
3+
pre:
4+
- BREAK
5+
- BREAKING
6+
- BRK
7+
- UPGRADE
8+
tags:
9+
- api-change
10+
- apichange
11+
bug:
12+
description: Bugs fixed
13+
pre:
14+
- FIX
15+
- BUG
16+
tags:
17+
- bug
18+
- bugfix
19+
- bugs
20+
deprecate:
21+
description: Deprecated features
22+
pre:
23+
- DEPRECATE
24+
- DEPRECATION
25+
- DEP
26+
tags:
27+
- deprecation
28+
- deprecate
29+
documentation:
30+
description: Documentation improvements
31+
pre:
32+
- DOC
33+
- DOCS
34+
tags:
35+
- documentation
36+
- docs
37+
- doc
38+
enhancement:
39+
description: Enhancements made
40+
pre:
41+
- NEW
42+
- ENH
43+
- ENHANCEMENT
44+
- IMPROVE
45+
tags:
46+
- enhancement
47+
- enhancements
48+
maintenance:
49+
description: Maintenance and upkeep improvements
50+
pre:
51+
- MAINT
52+
- MNT
53+
tags:
54+
- maintenance
55+
- maint
56+
new:
57+
description: New features added
58+
pre:
59+
- NEW
60+
- FEAT
61+
- FEATURE
62+
tags:
63+
- feature
64+
- new

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from glob import glob
55
from pathlib import Path
66

7-
init = Path().joinpath('github_activity', '__init__.py')
7+
init = Path().joinpath("github_activity", "__init__.py")
88
for line in init.read_text().split("\n"):
99
if line.startswith("__version__ ="):
1010
version = line.split(" = ")[-1].strip('"')
@@ -33,5 +33,8 @@
3333
use_package_data=True,
3434
entry_points={"console_scripts": ["github-activity = github_activity.cli:main",]},
3535
install_requires=install_packages,
36-
extras_require={"testing": ["pytest", "pytest-regressions"], "sphinx": ["sphinx", "myst_parser", "sphinx_book_theme"]},
36+
extras_require={
37+
"testing": ["pytest", "pytest-regressions"],
38+
"sphinx": ["sphinx", "myst_parser", "sphinx_book_theme"],
39+
},
3740
)

tests/test_cli.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ def test_cli(tmpdir, file_regression):
2222
file_regression.check(md, extension=".md")
2323

2424

25-
def test_tags(tmpdir, file_regression):
25+
def test_pr_split(tmpdir, file_regression):
26+
"""Test that PRs are properly split by tags/prefixes."""
2627
path_tmp = Path(tmpdir)
2728
path_output = path_tmp.joinpath("out.md")
2829

29-
url = "https://github.com/executablebooks/sphinx-book-theme"
30+
url = "https://github.com/executablebooks/jupyter-book"
3031

31-
# CLI with URL
32-
cmd = f"github-activity {url} -s v0.0.2 -u v0.0.4 -o {path_output}"
32+
# This release range covers some PRs with tags, and some with prefixes
33+
cmd = f"github-activity {url} -s v0.7.1 -u v0.7.3 -o {path_output}"
3334
out = run(cmd.split(), check=True)
3435
md = path_output.read_text()
36+
md = md.split("## Contributors to this release")[0]
3537
file_regression.check(md, extension=".md")

tests/test_cli/test_pr_split.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# v0.7.1...v0.7.3
2+
([full changelog](https://github.com/executablebooks/jupyter-book/compare/v0.7.1...v0.7.3))
3+
4+
5+
## New features added
6+
* ✨ NEW: Adding - chapter entries to _toc.yml [#817](https://github.com/executablebooks/jupyter-book/pull/817) ([@choldgraf](https://github.com/choldgraf))
7+
8+
## Enhancements made
9+
* 👌 IMPROVE: improving numbered sections [#826](https://github.com/executablebooks/jupyter-book/pull/826) ([@choldgraf](https://github.com/choldgraf))
10+
* ✨ NEW: Adding - chapter entries to _toc.yml [#817](https://github.com/executablebooks/jupyter-book/pull/817) ([@choldgraf](https://github.com/choldgraf))
11+
* checking for toc modification time [#772](https://github.com/executablebooks/jupyter-book/pull/772) ([@choldgraf](https://github.com/choldgraf))
12+
* first pass toc directive [#757](https://github.com/executablebooks/jupyter-book/pull/757) ([@choldgraf](https://github.com/choldgraf))
13+
14+
## Bugs fixed
15+
* Fix typo in content-blocks.md documentation [#811](https://github.com/executablebooks/jupyter-book/pull/811) ([@MaxGhenis](https://github.com/MaxGhenis))
16+
* [BUG] Using relative instead of absolute links [#747](https://github.com/executablebooks/jupyter-book/pull/747) ([@AakashGfude](https://github.com/AakashGfude))
17+
* 🐛 FIX: fixing jupytext install/UI links [#737](https://github.com/executablebooks/jupyter-book/pull/737) ([@chrisjsewell](https://github.com/chrisjsewell))
18+
19+
## Documentation improvements
20+
* 📚 DOC: update gh-pages + ghp-import docs [#814](https://github.com/executablebooks/jupyter-book/pull/814) ([@TomasBeuzen](https://github.com/TomasBeuzen))
21+
* 📚 DOC: note about licenses [#806](https://github.com/executablebooks/jupyter-book/pull/806) ([@choldgraf](https://github.com/choldgraf))
22+
* 📖 DOCS: Fix google analytics instructions [#799](https://github.com/executablebooks/jupyter-book/pull/799) ([@tobydriscoll](https://github.com/tobydriscoll))
23+
* Change book_path to path_to_book [#773](https://github.com/executablebooks/jupyter-book/pull/773) ([@MaxGhenis](https://github.com/MaxGhenis))
24+
* GitHub actions example: note about selective build [#771](https://github.com/executablebooks/jupyter-book/pull/771) ([@consideRatio](https://github.com/consideRatio))
25+
* getting sphinx thebelab to work [#749](https://github.com/executablebooks/jupyter-book/pull/749) ([@choldgraf](https://github.com/choldgraf))
26+
* Link documentation for adding cell tags in Jupyter from "Hide or remove content" documentation section [#734](https://github.com/executablebooks/jupyter-book/pull/734) ([@MaxGhenis](https://github.com/MaxGhenis))
27+
* typo fix [#731](https://github.com/executablebooks/jupyter-book/pull/731) ([@MaxGhenis](https://github.com/MaxGhenis))
28+
29+
## API and Breaking Changes
30+
* ✨ NEW: Adding - chapter entries to _toc.yml [#817](https://github.com/executablebooks/jupyter-book/pull/817) ([@choldgraf](https://github.com/choldgraf))
31+
* removing config file numbered sections to use toc file instead [#768](https://github.com/executablebooks/jupyter-book/pull/768) ([@choldgraf](https://github.com/choldgraf))
32+

tests/test_cli/test_tags.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)