Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic documentation #141

Merged
merged 31 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
03a7a42
Use Sphinx auto type hints
jlenain Jul 30, 2024
d80aca1
Use recursive autosummary, to have even more automation for doc building
jlenain Jul 30, 2024
3a1b06c
Follow configuration for recursive sphinx-autosummary from https://gi…
jlenain Jul 30, 2024
6566bdf
Adapt Sphinx makefile to clean _autosummary
jlenain Jul 30, 2024
d365412
Fix docstrings
jlenain Jul 30, 2024
09bbead
Add custom templates for sphinx-autosummary, from https://github.com/…
jlenain Jul 30, 2024
7c795ea
Fix docstrings
jlenain Jul 30, 2024
a9d8a15
Fix docstring
jlenain Jul 30, 2024
6d41422
Fix docstring
jlenain Jul 30, 2024
a19cd8d
Fix docstring
jlenain Jul 30, 2024
2edbc14
Fix docstring
jlenain Jul 30, 2024
20311ca
Fix docstring
jlenain Jul 30, 2024
f58352e
Fix docstring
jlenain Jul 30, 2024
1bffbd2
Add some inter-sphinx mappings
jlenain Jul 30, 2024
62d2c8a
Don't inherit docstrings from base classes
jlenain Jul 30, 2024
87b1c1d
Play by tweaking some doc options
jlenain Jul 31, 2024
72d4910
The order of imported Sphinx extensions matters
jlenain Jul 31, 2024
a723b8a
Re-add intersphinx mapping for ctapipe
jlenain Jul 31, 2024
996675b
Fix docstring
jlenain Jul 31, 2024
7f1710a
Doc template: avoid inheriting members in class template
jlenain Jul 31, 2024
c716034
Fix docstring
jlenain Jul 31, 2024
4690fcb
Fix PEP-8 coding style
jlenain Jul 31, 2024
6266527
Fix PEP-8 coding style
jlenain Jul 31, 2024
f82d2d8
Fix external URL in doc
jlenain Jul 31, 2024
c821de3
Logo for dark theme
jlenain Jul 31, 2024
144d307
Add PyPI and conda badges
jlenain Jul 31, 2024
f077f3b
Suppress warnings from sphinx.ext.autosummary
jlenain Jul 31, 2024
4facec4
Solve #137 by fetching all tags and history of repo in checkout actio…
jlenain Jul 31, 2024
5721187
Use mamba-org/setup-micromamba GitHub action instead of mamba-org/pro…
jlenain Jul 31, 2024
2c83422
Split on event type (#123)
vmarandon Jul 31, 2024
54c605e
Pin scipy version to 1.11.4, to avoid failures such as https://github…
jlenain Jul 31, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- name: Check out source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python environment
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -82,7 +84,7 @@ jobs:

- name: Mamba setup
if: matrix.install-method == 'mamba'
uses: mamba-org/provision-with-micromamba@v16
uses: mamba-org/setup-micromamba@v1
with:
environment-name: "ci"
environment-file: environment.yml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ src/nectarchain/user_scripts/**/test
**.log
**.pdf
**.csv
**.png

#VScode
.vscode/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nectarchain [![Build Status](https://github.com/cta-observatory/nectarchain/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cta-observatory/nectarchain/actions/workflows/ci.yml?query=workflow%3ACI+branch%3Amain)
# nectarchain [![Build Status](https://github.com/cta-observatory/nectarchain/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/cta-observatory/nectarchain/actions/workflows/ci.yml?query=workflow%3ACI+branch%3Amain) [![pypi](https://badge.fury.io/py/nectarchain.svg)](https://badge.fury.io/py/nectarchain) [![conda](https://anaconda.org/conda-forge/nectarchain/badges/version.svg)](https://anaconda.org/conda-forge/nectarchain)

Repository for the high level analysis of the NectarCAM data.
The analysis is heavily based on [ctapipe](https://github.com/cta-observatory/ctapipe), adding custom code for NectarCAM calibration.
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

clean:
rm -rf api
rm -rf _autosummary
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file removed docs/_static/nectarcam.png
Binary file not shown.
Binary file added docs/_static/nectarcam_logo.webp
Binary file not shown.
Binary file added docs/_static/nectarcam_logo_dark.webp
Binary file not shown.
33 changes: 33 additions & 0 deletions docs/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ fullname | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:special-members: __call__, __add__, __mul__

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
:nosignatures:
{% for item in methods %}
{%- if not item.startswith('_') %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
66 changes: 66 additions & 0 deletions docs/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
:nosignatures:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: custom-class-template.rst
:nosignatures:
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. autosummary::
:toctree:
:template: custom-module-template.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
11 changes: 0 additions & 11 deletions docs/api-reference/data/index.rst

This file was deleted.

10 changes: 0 additions & 10 deletions docs/api-reference/display/index.rst

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api-reference/dqm/index.rst

This file was deleted.

8 changes: 0 additions & 8 deletions docs/api-reference/index.rst

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api-reference/tools/index.rst

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api-reference/utils/index.rst

This file was deleted.

12 changes: 12 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
..
DO NOT DELETE THIS FILE! It contains the all-important `.. autosummary::` directive with `:recursive:` option, without
which API documentation wouldn't get extracted from docstrings by the `sphinx.ext.autosummary` engine. It is hidden
(not declared in any toctree) to remove an unnecessary intermediate page; index.rst instead points directly to the
package page. DO NOT REMOVE THIS FILE!

.. autosummary::
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:

nectarchain
38 changes: 26 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,25 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"numpydoc",
"sphinx_autodoc_typehints", # Automatically document param types (less noise in
# class signature)
]

numpydoc_show_class_members = False
autosummary_generate = True
autosummary_generate = True # Turn on sphinx.ext.autosummary
autoclass_content = "both" # Add __init__ doc (ie. params) to class summaries
html_show_sourcelink = (
False # Remove 'view source code' from top of page (for html, not python)
)
autodoc_inherit_docstrings = False # If no docstring, inherit from base class
set_type_checking_flag = True # Enable 'expensive' imports for sphinx_autodoc_typehints
nbsphinx_allow_errors = True # Continue through Jupyter errors
# autodoc_typehints = "description" # Sphinx-native method. Not as good as
# sphinx_autodoc_typehints
add_module_names = False # Remove namespaces from class/method signatures

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand All @@ -64,17 +71,19 @@
# The master toctree document.
master_doc = "index"

templates_path = [] # ["_templates"]
templates_path = ["_templates"]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# intersphinx allows referencing other packages sphinx docs
intersphinx_mapping = {
"python": ("https://docs.python.org/3.9", None),
"numpy": ("https://numpy.org/doc/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy", None),
"astropy": ("https://docs.astropy.org/en/latest/", None),
"ctapipe": ("https://ctapipe.readthedocs.io/en/v0.19.3/", None),
"matplotlib": ("https://matplotlib.org/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"traitlets": ("https://traitlets.readthedocs.io/en/stable/", None),
"ctapipe": ("https://ctapipe.readthedocs.io/en/v0.19.3/", None),
}

# These links are ignored in the checks, necessary due to broken intersphinx for these
Expand All @@ -95,6 +104,8 @@
("py:class", "ClassesType"),
]

suppress_warnings = ["autosummary"]

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

Expand All @@ -107,8 +118,6 @@
# Output file base name for HTML help builder.
htmlhelp_basename = f"{project}doc"

html_logo = "_static/nectarcam.png"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand All @@ -123,6 +132,11 @@
html_file_suffix = ".html"

html_theme_options = {
"logo": {
"image_light": "_static/nectarcam_logo.webp",
"image_dark": "_static/nectarcam_logo_dark.webp",
"alt_text": "nectarchain",
},
"navigation_with_keys": False,
"github_url": f"https://github.com/cta-observatory/{project}",
"navbar_start": ["navbar-logo", "version-switcher"],
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Welcome to nectarchain's documentation!
:hidden:

developer-guide/index
api-reference/index
API reference <_autosummary/nectarchain>


Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- pytest-runner
- pip
- pandas
- scipy=1.11
- scipy=1.11.4
- sphinx
- sphinx-automodapi
- pydata-sphinx-theme
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"ctapipe~=0.19",
"ctapipe-io-nectarcam",
"pandas",
"scipy==1.11",
"scipy==1.11.4",
"zodb",
"zeo",
]
Expand All @@ -48,6 +48,7 @@ dev = [

docs = [
"sphinx",
"sphinx-autodoc-typehints",
"sphinx-automodapi",
"pydata_sphinx_theme",
"numpydoc",
Expand Down
Loading
Loading