Skip to content

Commit

Permalink
Disambiguation project/package name. Added github_username to templating
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Panchenko committed Apr 29, 2024
1 parent b7eef62 commit a34b296
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The template includes CI/CD pipelines based on github actions. The documentation

In the documentation links to source code will be created, therefore you will be prompted to give the project's url.

See the resulting repository's [contributing guidelines]({{cookiecutter.project_name}}/docs/04_contributing/04_contributing.rst)
See the resulting repository's [contributing guidelines](docs/04_contributing/04_contributing.rst)
for further details. Some examples for projects following the general style of the template are [tianshou](https://github.com/thu-ml/tianshou)
and [armscan_env](https://github.com/appliedAI-Initiative/armscan_env/)

Expand Down
1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"project_name": "",
"author": "",
"author_email": "",
"github_username": "{{cookiecutter.author}}",
"package_name": "{{cookiecutter.project_name}}",
"python_version": ["3.11", "3.12"],
"project_url": "https://github.com/{{cookiecutter.author}}/{{cookiecutter.project_name}}",
Expand Down
6 changes: 3 additions & 3 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$"

project_name = "{{cookiecutter.project_name}}"
package_name = "{{cookiecutter.package_name}}"
project_url = "{{cookiecutter.project_url}}"

if not re.match(MODULE_REGEX, project_name):
if not re.match(MODULE_REGEX, package_name):
raise Exception(
f"The project name {project_name} is not a valid Python module name"
f"The project name {package_name} is not a valid Python module name"
)

if not project_url.startswith("http"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"outputs": [],
"source": [
"# Here an illustration of your library\n",
"from {{cookiecutter.project_name}}.sample_package.sample_module import hello_stranger\n",
"from {{cookiecutter.package_name}}.sample_package.sample_module import hello_stranger\n",
"\n",
"hello_stranger()"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Documentation Generation Test

We have the following three documentation tests:

1. pydocstyle (as part of ruff): test all docstring under ``{{cookiecutter.project_name}}/``;
1. pydocstyle (as part of ruff): test all docstrings;

2. doc8 (as part of ruff): test ReStructuredText format;

Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_name}}/docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ sphinx:
suppress_warnings: ["mystnb.unknown_mime_type"] # needed for plotly rendering
autodoc_show_sourcelink: True
add_module_names: False
github_username: {{cookiecutter.author}}
github_repository: {{cookiecutter.project_name}}
github_username: {{cookiecutter.github_username}}
github_repository: {{cookiecutter.project_url}}
python_use_unqualified_type_names: True
nb_mime_priority_overrides: [
[ 'html', 'application/vnd.jupyter.widget-view+json', 10 ],
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ max-complexity = 20
"docs/**" = ["D103"]
"examples/**" = ["D103"]

[tool.poetry_bumpversion.file."{{cookiecutter.project_name}}/__init__.py"]
[tool.poetry_bumpversion.file."{{cookiecutter.package_name}}/__init__.py"]

[tool.poetry-sort]
move-optionals-to-bottom = true
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/scripts/run_sample.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from {{cookiecutter.project_name}}.sample_module import SampleClass
from {{cookiecutter.package_name}}.sample_module import SampleClass

if __name__ == "__main__":
print(SampleClass().sample_method("{{cookiecutter.author}}"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, param: str | None = None):
self.param = param

def sample_method(self, name: str) -> str:
""">>> from {{cookiecutter.project_name}}.sample_module import SampleClass
""">>> from {{cookiecutter.package_name}}.sample_module import SampleClass
>>>
>>> greeter = SampleClass()
>>> greeter.sample_method("{{cookiecutter.author}}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from {{cookiecutter.project_name}}.sample_module import SampleClass
from {{cookiecutter.package_name}}.sample_module import SampleClass


# the suggested naming convention for unit tests is test_method_name_testDescriptionInCamelCase
Expand Down

0 comments on commit a34b296

Please sign in to comment.