Skip to content

Commit d5a8bd6

Browse files
committed
Merge branch 'main' into main-github
2 parents d28a29e + 09c0a20 commit d5a8bd6

15 files changed

Lines changed: 166 additions & 31 deletions

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ repos:
4141
--config,
4242
.vscode/cspell.json,
4343
]
44+
- repo: https://github.com/bjd2385/pre-commit-gitlabci-lint
45+
rev: v1.3.0
46+
hooks:
47+
- id: gitlabci-lint
48+
args: ["-p", "46207681"] # project id is required, but any will do
49+
entry: env GITLAB_TOKEN=w8i5Q1CaEpF57cqxezvG gitlabci-lint
50+
files: "^\\.gitlab-ci\\.yml$"

.vscode/terms.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
asprunner
2+
autoapi
3+
autodoc
14
automodule
25
BUILDDIR
36
bumpversion
@@ -6,16 +9,20 @@ cyclomatic
69
docstrings
710
Docutils
811
endfor
12+
fraunhofer
913
Furo
1014
gitfile
1115
gitlab
16+
gitlabci
1217
gitmoji
1318
glab
1419
includex
20+
Jannis
1521
jannismain
1622
jimustafa
1723
jinja
1824
magiclink
25+
Mainczyk
1926
mkdocs
2027
mkdocstrings
2128
myst

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
### Added
11+
12+
- automatically assign `asprunner` tag in GitLab CI configuration intended for `gitlab-fhg` remote.
13+
- GitLab CI artifacts are set to expire after 1 week to reduce overall storage usage (most recent artifact is kept)
14+
- pre-commit hook that lints `.gitlab-ci.yml` and prevents committing a faulty config
15+
- available for projects with gitlab remote using mkdocs
16+
17+
### Changed
18+
19+
- replace sphinx-autodoc2 with sphinx-autoapi for better google-style docstring support
20+
21+
### Fixed
22+
23+
- Gitlab projects using mkdocs didn't install doc requirements during CI
24+
- docstring argument section not parsed correctly
25+
1026
## [0.0.5] - 2023-09-25
1127

1228
### Fixed

DEPENDENCIES

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016 The Python Packaging Authority (PyPA)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2023 Jannis Mainczyk
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
20+
OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build/examples/gitlab_fhg: INIT_PYTHON_PROJECT_ARGS+=--remote=gitlab-fhg --remot
1818
build/examples/gitlab_iis: INIT_PYTHON_PROJECT_ARGS+=--remote=gitlab-iis --remote-url=git@git01.iis.fhg.de:mkj/sample-project.git
1919
build/examples/gitlab_iis_sphinx: INIT_PYTHON_PROJECT_ARGS+=--remote=gitlab-iis --remote-url=git@git01.iis.fhg.de:mkj/sample-project-sphinx.git --docs=sphinx
2020

21-
$(PUBLISHED_EXAMPLES): uncopy-template copy-template
21+
$(PUBLISHED_EXAMPLES): uncopy-template link-template
2222
@echo "Recreating '$@'..."
2323
@rm -rf "$@" && mkdir -p "$@"
2424
init-python-project "$@" ${INIT_PYTHON_PROJECT_ARGS} --defaults --yes --verbose
@@ -124,6 +124,10 @@ copy-template:
124124
@cp copier.yaml ${PKGDIR}/.
125125
uncopy-template:
126126
@rm -rf ${TEMPLATE_DEST} ${PKGDIR}/copier.yaml
127+
link-template:
128+
@cd ${PKGDIR} &&\
129+
ln -s ../../${TEMPLATE_SRC} template &&\
130+
ln -s ../../copier.yaml copier.yaml
127131
build-clean: uncopy-template ## remove build artifacts
128132
@rm -rf ${BUILDDIR}
129133

docs/developer-guide/release.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Releasing a new version
2+
3+
As this repository is hosted on three different remotes to reach different target audiences ([Fraunhofer IIS internal](https://git01.iis.fhg.de), [FHG internal](https://gitlab.cc-asp.fraunhofer.de) and [public](https://github.com/jannismain/python-project-template)), it is convenient to have their respective main branches all available under different names in your local repository:
4+
5+
```
6+
git remote add origin git@git01.iis.fhg.de:mkj/project-template.git
7+
git checkout main
8+
git remote add fhg git@gitlab.cc-asp.fraunhofer.de:mkj/project-template.git
9+
git remote add github git@github.com:jannismain/python-project-template.git
10+
git branch --set-upstream-to=fhg/main main-fhg
11+
git branch --set-upstream-to=github/main main-github
12+
```
13+
14+
Each of those remotes host a version of the project template with links updated to point to that remote. Therefore, updates cannot be simply pushed to those remotes but need to be merged into their main branches, so that the platform-specific changes remain intact.
15+
16+
With those preparations in place, a new release can be created like this:
17+
18+
1. Commit everything that should be part of the release to be `main` branch of the IIS-internal version of the repository. That includes updating the CHANGELOG and bumping the version number.
19+
2. Merge those changes into the `main` branches of the fhg and public remotes.
20+
21+
```
22+
git co main-fhg
23+
git merge main --ff-only --ff
24+
git co main-github
25+
git merge main --ff-only --ff
26+
```
27+
28+
3. Trigger the release process on the public `main` branch
29+
30+
```
31+
make release
32+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Template in Package
2+
3+
## Summary
4+
5+
- use `make copy-template` before building a package.
6+
- use `make link-template` during development with an in-place installation.
7+
8+
## Explanation
9+
10+
Copier templates require a `copier.yaml` in the root of the git project in order to be discovered during `copier copy gh:jannismain/python-project-template`.
11+
12+
However, for distribution of the template as a Python package, the template files need to be part of the Python package in `src/init_python_project/`.
13+
So when building a package using `make build`, the template files are copied into the package using `make copy-template`.
14+
15+
During development, a copy is impractical, as changes to the template are not picked up by `init-python-project`, which still uses the (now out-of-date) copy inside the package. For this reason, it is useful to *link* the template into the package using `make link-template`. Those symbolic links are not supported when building a Python package, so they are replaced the next time a package is created.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ authors = [{ name = "Jannis Mainczyk", email = "jmainczyk@gmail.com" }]
1111
maintainers = [{ name = "Jannis Mainczyk", email = "jmainczyk@gmail.com" }]
1212
dependencies = ["copier", "typer[all]"]
1313
dynamic = ["version"]
14+
license = { file = "LICENSE", type = "MIT" }
1415

1516
[tool.setuptools_scm]
1617
fallback_version = "0.0.0"

template/{% if docs == 'sphinx' and docs_template=='none' %}docs{% endif %}/conf.py.jinja

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,15 @@ myst_enable_extensions = [
3838
"colon_fence", # https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#markdown-figures
3939
]
4040

41-
# -- Options for sphinx-autodoc2 ---------------------------------------------
42-
# https://sphinx-autodoc2.readthedocs.io/en/latest/config.html
41+
# -- Options for sphinx-autoapi ----------------------------------------------
42+
# https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html
4343

44-
extensions += ["autodoc2"] # https://sphinx-autodoc2.readthedocs.io/
45-
46-
autodoc2_output_dir = "apidocs"
47-
autodoc2_packages = [
48-
"../src/{{package_name}}",
44+
extensions += [
45+
"sphinx.ext.napoleon", # required to parse google-style docstrings
46+
"sphinx.ext.autodoc", # required to parse typehints
47+
"autoapi.extension",
4948
]
50-
autodoc2_render_plugin = "md"
51-
{% raw %}
52-
autodoc2_index_template = """
53-
API Documentation
54-
=================
55-
56-
.. toctree::
57-
:titlesonly:
58-
{% for package in top_level %}
59-
{{ package }}
60-
{%- endfor %}
61-
"""
62-
{% endraw -%}
49+
autoapi_dirs = ["../src/{{package_name}}"]
50+
51+
# https://sphinx-autoapi.readthedocs.io/en/latest/how_to.html#how-to-include-type-annotations-as-types-in-rendered-docstrings
52+
autodoc_typehints = "description"

0 commit comments

Comments
 (0)