Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d3c74f6
Improve doc content #58
richarddushime Mar 3, 2025
f882987
Github repos creation
richarddushime Mar 3, 2025
c20945b
Fix pre-commit issues
richarddushime Mar 3, 2025
acecc88
title update
richarddushime Mar 5, 2025
43f7a9c
description
richarddushime Mar 5, 2025
5279ba8
Fix Requested Changes
richarddushime Mar 5, 2025
b82c0a0
improved layout
richarddushime Mar 6, 2025
dc847e8
Update .github/workflows/cookiecutter_docs.yml
richarddushime Mar 7, 2025
2fac121
Update docs/source/conf.py
richarddushime Mar 7, 2025
7708016
Update docs/source/conf.py
richarddushime Mar 7, 2025
bbad1ee
Update docs/source/index.md
richarddushime Mar 7, 2025
bbfa393
Update docs/source/project_setup.md
richarddushime Mar 7, 2025
ccb30f4
Update docs/source/project_setup.md
richarddushime Mar 7, 2025
13cdc82
Update docs/source/contributing.md
richarddushime Mar 7, 2025
3d7ec7a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 7, 2025
067a818
Update docs/source/contributing.md
richarddushime Mar 7, 2025
d9d5efb
Update docs/source/contributing.md
richarddushime Mar 7, 2025
a860e1a
Update docs/source/contributing.md
richarddushime Mar 7, 2025
1db8ebd
Update docs/source/get_started.md
richarddushime Mar 7, 2025
353e9aa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 7, 2025
1c7341b
Update docs/source/index.md
richarddushime Mar 7, 2025
0ffa2a8
Update docs/source/project_setup.md
richarddushime Mar 7, 2025
7855823
Minor Requested changes
richarddushime Mar 7, 2025
9b67998
Update README.md
richarddushime Mar 10, 2025
be81e07
Update README.md
richarddushime Mar 10, 2025
31618c5
Update docs/source/modules.md
richarddushime Mar 10, 2025
921f001
Restructuring the Navbar and Contents
richarddushime Mar 10, 2025
eded354
Minor Fixes
richarddushime Mar 10, 2025
4a2d475
Update docs/source/index.md
richarddushime Mar 11, 2025
e82601c
Update docs/source/index.md
richarddushime Mar 11, 2025
01b656a
Update docs/source/index.md
richarddushime Mar 11, 2025
56a7686
Update docs/source/contributing.md
richarddushime Mar 11, 2025
8575e62
Final
richarddushime Mar 11, 2025
0717d5d
lints errors fix
richarddushime Mar 12, 2025
92ccf06
lints fix
richarddushime Mar 12, 2025
44323ff
Merge branch 'main' into sphnix-docs
adamltyson Mar 12, 2025
865fff7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
31 changes: 31 additions & 0 deletions .github/workflows/cookiecutter_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Documentation
on:
push:
branches: [main]
tags: ['*']

jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.13'

- name: Install dependencies
run: |
pip install -r docs/requirements.txt

- name: Build docs
run: |
cd docs
make clean && make html

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html
Empty file added docs/.nojekyll
Empty file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
myst-parser
pydata-sphinx-theme
sphinx
59 changes: 59 additions & 0 deletions docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Top navbar */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.8rem 2rem;
background: transparent;
}

.navbar-brand {
flex: 0 0 auto;
}

.navbar-center-group {
flex: 1;
display: flex;
justify-content: center;
gap: 2rem;
margin: 0 2rem;
float: right;
}

.navbar-nav {
display: flex;
gap: 1.5rem;
margin: 0;
padding: 0;
align-items: center;
}

.navbar-icons {
display: flex;
gap: 1.5rem;
align-items: center;
}

.navbar-brand-logo img { height: 40px; }
.nav-link { color: white !important; font-weight: 500; }
.icon-link { color: white !important; font-size: 1.2rem; }
.bd-sidebar-secondary { display: none !important; }

/* Mobile responsiveness */
@media (max-width: 768px) {
.navbar {
flex-wrap: wrap;
padding: 0.8rem;
}

.navbar-center-group {
order: 2;
width: 100%;
margin: 1rem 0;
justify-content: center;
}

.navbar-brand {
order: 1;
}
}
Binary file added docs/source/_static/favicon.ico
Binary file not shown.
Binary file added docs/source/_static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/source/_templates/navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<nav class="bd-navbar navbar">
<!-- Center: Navigation items -->
<div class="navbar-center-group">
<ul class="nav navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ pathto('index') }}">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ pathto('contributing') }}">Contribute</a>
</li>
</ul>
</div>

</nav>
7 changes: 7 additions & 0 deletions docs/source/_templates/sidebar-nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="sidebar-header-items__center">
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item navbar-nav">
{{ toctree(maxdepth=2, includehidden=True, collapse=False) }}
</div>
</nav>
</div>
91 changes: 91 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# conf.py
# Configuration file for the Sphinx documentation builder.
project = 'cookiecutter-python'
copyright = "2025, Neuroinformatics Unit"
author = 'NIU'
release = "1.0.0"

# -- General configuration ---------------------------------------------------
extensions = [
"myst_parser",
"sphinx_design",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.githubpages",
"sphinx_autodoc_typehints",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx_sitemap",
"nbsphinx",
]

# Configure MyST Parser
myst_enable_extensions = [
"colon_fence",
"deflist",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"substitution",
"tasklist",
"attrs_inline"
]

myst_heading_anchors = 4

source_suffix = {
'.md': 'markdown',
'.rst': 'restructuredtext'
}

templates_path = ['_templates']
exclude_patterns = [
"**.ipynb_checkpoints",
"**/includes/**",
]

# -- HTML output options -----------------------------------------------------
html_theme = 'pydata_sphinx_theme'
html_logo = "_static/logo.png"
html_static_path = ["_static"]
html_title = "Python Cookiecutter"
html_favicon = "_static/favicon.ico"
html_show_sourcelink = False

html_theme_options = {
"navbar_start": ["navbar-logo"],
"navbar_center": ["navbar.html"],
"navbar_end": ["theme-switcher", "navbar-icon-links"],
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/neuroinformatics-unit/python-cookiecutter",
"icon": "fa-brands fa-github",
"type": "fontawesome",
}
],
"logo": {
"text": "Python Cookiecutter",
"image_light": "logo.png",
"image_dark": "logo.png",
},
"show_nav_level": 2,
"navigation_depth": 3,
"collapse_navigation": True,
}

# Sitemap configuration
html_baseurl = "https://neuroinformatics-unit.github.io/python-cookiecutter/"
sitemap_url_scheme = "{link}"


html_sidebars = {
"**": ["sidebar-nav.html"]
}

def setup(app):
app.add_css_file("css/custom.css")
81 changes: 81 additions & 0 deletions docs/source/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing to cookiecutter-python

Thank you for considering contributing to cookiecutter-python! We welcome contributions that improve the project, whether it's code,
documentation, or enhancements.

Please follow the guidelines below to ensure a smooth process.

1. **Fork and Clone the Repository** Fork the main repository on
GitHub, then clone your fork locally:

``` sh
git clone https://github.com/<your-username>/python-cookiecutter.git
cd python-cookiecutter
```

2. **Create a New Branch** Create and switch to a new branch for your
changes:

``` sh
git checkout -b my_new_feature
```

3. **Make Your Changes** Edit the content, code, or
documentation as needed. When you're ready, add and commit your
changes with a descriptive message:

``` sh
git add .
git commit -m "Describe your changes in short here"
```

4. **Push Your Branch and Create a Pull Request** Push the new branch
to GitHub:

``` sh
git push origin --set-upstream origin my_new_feature
```

Then, open a pull request against the ``main`` branch of the main repository. This will automatically trigger a GitHub Action to verify that the builds correctly.

5. **Review and Merge** If the build checks pass, assign someone to review your pull request. Once approved and merged into the ``main`` branch, another GitHub Action will build and add your changes to the ``main`` branch.


## Documentation Local Testing

If you are contributing to the Documentation, Before pushing your changes, you can test locally:

- **First-Time Setup:** Install the required dependencies and build
the docs:

``` sh
pip install -r docs/requirements.txt
sphinx-build docs/source docs/build
```

Alternatively, you can use the following commands to install the
dependencies and build the docs:

``` sh
pip install -r docs/requirements.txt
cd docs
make html
```

- **Rebuilding:** Each time you update the documentation,
rebuild the docs by running:

``` sh
rm -rf docs/build && sphinx-build docs/source docs/build
```
or

```sh
cd docs
make clean && make html
```

Then, open `docs/build/index.html` in your browser to preview the changes.


Thank you for your contributions!
38 changes: 38 additions & 0 deletions docs/source/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Documentation

Software documentation is important for effectively communicating how to use the software to others as well as to your future self.

If you want to include documentation in your package, make sure to respond with `1 - Yes` when prompted during the `cookiecutter` setup. This will instantiate a `docs` folder with a skeleton documentation system, that you can build upon.

The documentation source files are located in the `docs/source` folder and should be written in either [reStructuredText](https://docutils.sourceforge.io/rst.html) or [markdown](https://myst-parser.readthedocs.io/en/stable/syntax/typography.html). The `index.rst` file corresponds to the main page of the documentation website. Other `.rst` or `.md` files can be included in the main page via the `toctree` directive.

The documentation is built using [Sphinx](https://www.sphinx-doc.org/en/master/) and the [PyData Sphinx Theme](https://pydata-sphinx-theme.readthedocs.io/en/latest/). The `docs/source/conf.py` file contains the `Sphinx` configuration.

## Building the documentation locally
You can build and view the documentation website locally, on your machine. To do so, run the following commands from the root of your project:

```sh
# Install the documentation build dependencies
pip install -r docs/requirements.txt
# Build the documentation
sphinx-build docs/source docs/build
```
This should create a `docs/build` folder. You can view the local build by opening `docs/build/index.html` in a browser.
To refresh the documentation, after making changes, remove the `docs/build` folder and re-run the above command:

```sh
rm -rf docs/build
sphinx-build docs/source docs/build
```

### Publishing the documentation
We have included an extra GitHub actions workflow in `.github/workflows/docs_build_and_deploy.yml` that will build the documentation and deploy it to [GitHub pages](https://pages.github.com/).
* The build step is triggered every time a pull request is opened or a push is made to the `main` branch. This way you can make sure that the documentation does not break before merging your changes.
* The deployment is triggered only when a tag is present (see [Automated versioning](versioning.md)). This ensures that new documentation versions are published in tandem with the release of a new package version on PyPI (see [GitHub actions workflow](github_actions_setup.md)).
* The published docs are by default hosted at `https://<github_username_or_organization>.github.io/<package_name>/`. To enable hosting, you will need to go to the settings of your repository, and under the "Pages" section, select the `gh-pages` branch as the source for your GitHub pages site.
* A popular alternative to GitHub pages for hosting the documentation is [Read the Docs](https://readthedocs.org/). To enable hosting on Read the Docs, you will need to create an account on the website and follow the instructions to link your GitHub repository to your Read the Docs account.

### Docstrings and API documentation
The journey towards good documentation starts with writing docstrings for all functions in your module code. In the example `math.py` and `greetings.py` modules you will find some docstrings that you can use as a template. We have written the example docstrings following the [numpy style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_numpy.html) but you may also choose another widely used style, such as the [Google style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).

Once you have written docstrings for all your functions, API documentation can be automatically generated via the [Sphinx autodoc extension](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html). We have given examples of how to do this in the `docs/source/api_index.rst` file.
8 changes: 8 additions & 0 deletions docs/source/github_actions_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# GitHub actions workflow

A GitHub actions workflow (`.github/workflows/test_and_deploy.yml`) has been set up to run (on each commit/PR):
* Linting checks (pre-commit).
* Testing (only if linting checks pass)
* Release to PyPI (only if a git tag is present and if tests pass). Requires `TWINE_API_KEY` from PyPI to be set in repository secrets.

This automation ensures that each commit or pull request is validated and that releases are published only when all checks pass.
Loading