Skip to content

Commit ca1966d

Browse files
authored
Minor changes to improve UX (#3)
Update tests, docstring, README etc.
1 parent fb83f67 commit ca1966d

File tree

7 files changed

+64
-17
lines changed

7 files changed

+64
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Version 0.1.1
4+
5+
Minor changes to improve user experience.
6+
37
## Version 0.1.0
48

59
- Uses PyScaffold with Markdown extension for base project structure
@@ -10,4 +14,4 @@
1014
- Furo theme
1115
- Type hints documentation
1216
- Adds Ruff configuration for consistent code formatting
13-
- Creates standardized README with PyPI and CI badges
17+
- Creates README

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ create_repository(
4444
)
4545
```
4646

47+
## After setup
48+
49+
- (Optional) Enable [pre-commit.ci](https://pre-commit.ci/) bot for your new repository.
50+
- (Optional) Install [ruff](https://docs.astral.sh/ruff/) for code formatting.
51+
4752
<!-- pyscaffold-notes -->
4853

4954
## Note

docs/conf.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171

172172
# The theme to use for HTML and HTML Help pages. See the documentation for
173173
# a list of builtin themes.
174-
html_theme = "alabaster"
174+
html_theme = "furo"
175175

176176
# Theme options are theme-specific and customize the look and feel of a theme
177177
# further. For a list of options available for each theme, see the
@@ -301,4 +301,21 @@
301301
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
302302
}
303303

304-
print(f"loading configurations for {project} {version} ...", file=sys.stderr)
304+
print(f"loading configurations for {project} {version} ...", file=sys.stderr)
305+
306+
# -- Biocsetup configuration -------------------------------------------------
307+
308+
# Enable execution of code chunks in markdown
309+
extensions.append('myst_nb')
310+
311+
# Less verbose api documentation
312+
extensions.append('sphinx_autodoc_typehints')
313+
314+
autodoc_default_options = {
315+
"special-members": True,
316+
"undoc-members": True,
317+
"exclude-members": "__weakref__, __dict__, __str__, __module__",
318+
}
319+
320+
autosummary_generate = True
321+
autosummary_imported_members = True

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
furo
12
# Requirements file for ReadTheDocs, check .readthedocs.yml.
23
# To build the module reference correctly, make sure every external package
34
# under `install_requires` in `setup.cfg` is also listed here!

src/biocsetup/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
@click.command()
1111
@click.argument("project_path")
12-
@click.option("--description", "-d", help="Project description")
12+
@click.option("--description", "-d", help="Project description", default="Add a short description here!")
1313
@click.option("--license", "-l", default="MIT", help="License (default: MIT)")
1414
def main(project_path: str, description: str, license: str):
15-
"""Create a new Python package repository with consistent configuration."""
15+
"""Create a new BiocPy Python package."""
1616
create_repository(
1717
project_path=project_path,
1818
description=description,

src/biocsetup/create_repository.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33
from typing import Optional
44

5-
from pyscaffold import api
5+
from pyscaffold import api, file_system, shell
66
from pyscaffoldext.markdown.extension import Markdown
77

88
__author__ = "Jayaram Kancherla"
@@ -12,31 +12,37 @@
1212

1313
def create_repository(
1414
project_path: str,
15-
description: Optional[str] = None,
15+
description: Optional[str] = "Add a short description here!",
1616
license: str = "MIT",
1717
) -> None:
1818
"""
1919
Create a new BiocPy Python package repository.
2020
2121
Args:
2222
project_path:
23-
Path where the new project should be created
23+
Path where the new project should be created.
2424
2525
description:
26-
Optional project description
26+
Optional project description.
2727
2828
license:
29-
License to use (default: MIT)
29+
License to use.
30+
Defaults to 'MIT'.
3031
"""
3132
# Create project using pyscaffold with markdown extension
33+
if description is None:
34+
description = "Add a short description here!"
35+
3236
opts = {
3337
"project_path": project_path,
34-
"description": description or "Add a short description here!",
38+
"description": description,
3539
"license": license,
3640
"extensions": [Markdown()],
3741
}
3842
api.create_project(**opts)
3943

44+
modified_files = []
45+
4046
# Get absolute path to templates directory
4147
template_dir = Path(__file__).parent / "templates"
4248

@@ -48,11 +54,13 @@ def create_repository(
4854
src = template_dir / "github_workflows" / workflow
4955
dst = gh_actions_dir / workflow
5056
shutil.copy2(src, dst)
57+
modified_files.append(dst)
5158

5259
# Add pre-commit config
5360
precommit_src = template_dir / "precommit" / "pre-commit-config.yaml"
5461
precommit_dst = Path(project_path) / ".pre-commit-config.yaml"
5562
shutil.copy2(precommit_src, precommit_dst)
63+
modified_files.append(precommit_dst)
5664

5765
# Modify sphinx conf.py
5866
conf_py_path = Path(project_path) / "docs" / "conf.py"
@@ -61,6 +69,7 @@ def create_repository(
6169

6270
# Add myst-nb extension and configuration
6371
myst_config = """
72+
6473
# -- Biocsetup configuration -------------------------------------------------
6574
6675
# Enable execution of code chunks in markdown
@@ -77,24 +86,25 @@ def create_repository(
7786
7887
autosummary_generate = True
7988
autosummary_imported_members = True
80-
81-
html_theme = "furo"
8289
"""
8390

91+
conf_content = conf_content.replace("alabaster", "furo")
92+
8493
with open(conf_py_path, "w") as f:
8594
f.write(conf_content + myst_config)
95+
modified_files.append(conf_py_path)
8696

8797
# Update requirements.txt for docs
8898
docs_requirements = Path(project_path) / "docs" / "requirements.txt"
8999
with open(docs_requirements, "a") as f:
90-
f.write("\nmyst-nb\nfuro\nsphinx-autodoc-typehints\n")
100+
f.write("myst-nb\nfuro\nsphinx-autodoc-typehints\n")
101+
modified_files.append(docs_requirements)
91102

92103
# Modify README
93104
readme_path = Path(project_path) / "README.md"
94105
proj_name = Path(project_path).parts[-1]
95106

96-
new_readme = f"""
97-
[![PyPI-Server](https://img.shields.io/pypi/v/{proj_name}.svg)](https://pypi.org/project/{proj_name}/)
107+
new_readme = f"""[![PyPI-Server](https://img.shields.io/pypi/v/{proj_name}.svg)](https://pypi.org/project/{proj_name}/)
98108
![Unit tests](https://github.com/BiocPy/{proj_name}/actions/workflows/pypi-test.yml/badge.svg)
99109
100110
# {proj_name}
@@ -121,6 +131,7 @@ def create_repository(
121131

122132
with open(readme_path, "w") as f:
123133
f.write(new_readme)
134+
modified_files.append(readme_path)
124135

125136
# Modify ppyproject.toml to add ruff configuration
126137
pyprj_path = Path(project_path) / "pyproject.toml"
@@ -147,3 +158,12 @@ def create_repository(
147158

148159
with open(pyprj_path, "w") as f:
149160
f.write(pyprj_content + ruff_config)
161+
modified_files.append(pyprj_path)
162+
163+
with file_system.chdir(project_path):
164+
for f in modified_files:
165+
shell.git("add", str(f.relative_to(project_path)))
166+
167+
shell.git("commit", "-m", "BiocSetup configuration")
168+
169+
print("BiocSetup complete! 🚀 💥")

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ def test_cli_help():
6666
runner = CliRunner()
6767
result = runner.invoke(main, ["--help"])
6868
assert result.exit_code == 0
69-
assert "Create a new Python package repository" in result.output
69+
assert "Create a new BiocPy Python package" in result.output
7070
assert "--description" in result.output
7171
assert "--license" in result.output

0 commit comments

Comments
 (0)