Skip to content

Commit 41ee755

Browse files
authored
Eac/docs (#177)
* WIP on docs * WIP, docs * updated docs to autogenerate lots of stuff * updated .gitignore to ignore locally rendered jupyter notebooks * tweak docs/conf.py * adding some content to docs * doc updates
1 parent 481aebf commit 41ee755

16 files changed

+637
-111
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ instance/
7171

7272
# Sphinx documentation
7373
docs/_build/
74+
docs/api
75+
docs/api.rst
7476
_readthedocs/
77+
docs/*_examples/*.html
7578

7679
# PyBuilder
7780
target/

docs/conf.py

+29-13
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
import subprocess
1717
import sys
1818
sys.path.insert(0, os.path.abspath('..'))
19+
1920
import rail
21+
2022
from rail.core import RailEnv
2123

2224
for rail_path in rail.__path__:
2325
sys.path.insert(0, rail_path)
2426

25-
print(sys.path)
26-
2727

2828
# Use unittest mock module to shield some modules away from docs building.
2929
# This way one does not need to install them when dealing with the doc.
@@ -46,11 +46,14 @@
4646
'fsps',
4747
'dsps',
4848
'dsps.cosmology',
49+
'lephare',
4950
'pzflow',
5051
'pzflow.bijectors',
5152
'sklearn',
5253
'sklearn.cluster',
5354
'sklearn.decomposition',
55+
'sklearn.tree',
56+
'sklearn.ensemble',
5457
'gal_pop_model_components',
5558
'qp_flexzboost',
5659
]
@@ -97,6 +100,7 @@
97100
'sphinx.ext.napoleon',
98101
'sphinx.ext.autosectionlabel',
99102
'sphinx_tabs.tabs',
103+
'sphinx_click',
100104
]
101105

102106
# Add any paths that contain templates here, relative to this directory.
@@ -130,6 +134,25 @@
130134
# Allow NB to fail
131135
nbsphinx_allow_errors = True
132136

137+
# use type hints in autodoc
138+
autodoc_typehints = "description"
139+
140+
autodoc_type_aliases = {
141+
'DataLike': 'rail.core.data.DataLike',
142+
'FileLike': 'rail.core.data.FileLike',
143+
'GroupLike': 'rail.core.data.GroupLike',
144+
'ModelLike': 'rail.core.data.ModelLike',
145+
'TableLike': 'rail.core.data.TableLike',
146+
}
147+
148+
autodoc_class_signature = "separated"
149+
150+
autodoc_default_options = {
151+
'special-members': '__init__',
152+
'undoc-members': True,
153+
'exclude-members': 'config_options'
154+
}
155+
133156
# By default, tabs can be closed by selecting the open tab. This
134157
# functionality can be disabled using the sphinx_tabs_disable_tab_closing
135158
# configuration option:
@@ -192,19 +215,12 @@
192215
# from sphinxcontrib.apidoc import main as apidoc_main
193216

194217
def run_apidoc(_):
195-
#os.system('ln -s ../examples')
196-
197-
from sphinx.ext.apidoc import main as apidoc_main
198-
cur_dir = os.path.normpath(os.path.dirname(__file__))
199-
output_path = os.path.join(cur_dir, 'api')
200-
201-
for full_path in rail.__path__:
202-
paramlist = ['--separate', '--implicit-namespaces', '--no-toc', '-M', '-o', output_path, '-f', full_path]
203-
print(f"running {paramlist}")
204-
apidoc_main(paramlist)
205218

219+
if os.environ.get('RAIL_NO_REBUILD_API', False):
220+
return
221+
RailEnv.do_stage_type_api_rst()
206222
RailEnv.do_api_rst()
207-
223+
208224

209225
def setup(app):
210226
app.connect('builder-inited', run_apidoc)

docs/demos.rst

-51
This file was deleted.

docs/index.rst

+26-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,37 @@ To get involved, chime in on the issues in any of the RAIL repositories describe
1212

1313

1414
.. toctree::
15-
:maxdepth: 1
15+
:maxdepth: 4
1616
:caption: Getting Started
1717

1818
source/overview
1919
source/installation
2020
source/citing
2121

2222
.. toctree::
23-
:maxdepth: 1
23+
:maxdepth: 4
24+
:caption: Concepts
25+
26+
source/stages
27+
source/data_handles
28+
source/pipelines
29+
source/catalog_tags
30+
31+
.. toctree::
32+
:maxdepth: 4
33+
:caption: Details
34+
35+
source/documentation
36+
api/stage_types
37+
38+
.. toctree::
39+
:maxdepth: 4
40+
:caption: Usage
41+
42+
source/rail_cli
43+
44+
.. toctree::
45+
:maxdepth: 4
2446
:caption: Contributing
2547

2648
source/contributing
@@ -30,13 +52,13 @@ To get involved, chime in on the issues in any of the RAIL repositories describe
3052
source/sharing_pipeline
3153

3254
.. toctree::
33-
:maxdepth: 1
55+
:maxdepth: 5
3456
:caption: API
3557

3658
api
3759

3860
.. toctree::
39-
:maxdepth: 1
61+
:maxdepth: 4
4062
:caption: Usage Demos
4163

4264
Overview of Demonstrations <source/demonstrations>

docs/source/catalog_tags.rst

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
*******************************
2+
Configuring RAIL for input data
3+
*******************************
4+
5+
====================================
6+
Variation in input catalog structure
7+
====================================
8+
9+
`RAIL` is designed to be used with a variety of different data.
10+
Depending on the data in question, things like the names of the
11+
columns associted to the particular quantities like the true redshift
12+
of a simulated object, or the names of the columns with the various
13+
observed magnitudes in different filters, will vary. By enforcing
14+
consistency in naming conventions between different `RailStage`
15+
sub-classes we have made it simple configure `RAIL` to read data from
16+
a particular source, rather than having to edit the configurations
17+
for many different `RailStages`.
18+
19+
=================
20+
Shared Parameters
21+
=================
22+
23+
.. autoclass:: rail.core.common_params.SharedParams
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:
27+
28+
29+
============
30+
Catalog Tags
31+
============
32+
33+
:py:class:`rail.util.catalog_utils.CatalogConfigBase` provides an
34+
interface to switch between different input catalogs.
35+
36+
.. autoclass:: rail.utils.catalog_utils.CatalogConfigBase
37+
:noindex:
38+
39+
.. automethod:: rail.utils.catalog_utils.CatalogConfigBase.apply
40+
:noindex:
41+
42+
.. automethod:: rail.utils.catalog_utils.CatalogConfigBase.active_class
43+
:noindex:
44+
45+
.. automethod:: rail.utils.catalog_utils.CatalogConfigBase.active_tag
46+
:noindex:

docs/source/contributing.rst

+34-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ RAIL is a constellation of multiple packages developed publicly on GitHub and
66
welcomes all interested developers, regardless of DESC membership or LSST data rights.
77

88
If you're interested in contributing, but don't know where to start, take a look
9-
at the list of good first issues from all RAIL repositories
10-
`here <https://github.com/orgs/LSSTDESC/projects/6/views/20>`_.
11-
Or, create a new issue `here <https://github.com/LSSTDESC/rail/issues/new>`_ to
9+
at the list of `good first issues from all RAIL repositories <https://github.com/orgs/LSSTDESC/projects/6/views/20>`_.
10+
Or, `create a new issue <https://github.com/LSSTDESC/rail/issues/new>`_ to
1211
suggest a change, and the team will route it to the appropriate repository.
1312

1413
In addition to GitHub, the RAIL team uses the LSSTC Slack workspace for organization.
@@ -19,7 +18,7 @@ the `\#desc-pz-rail <https://lsstc.slack.com/archives/CQGKM0WKD>`_ channel on
1918
the LSSTC Slack workspace.
2019

2120
Those without data rights who wish to gain access to the Slack channel should
22-
`create an Issue <https://github.com/LSSTDESC/RAIL/issues/new>`_ to request that
21+
`create an issue <https://github.com/LSSTDESC/RAIL/issues/new>`_ to request that
2322
the team leads initiate the process for adding a DESC External Collaborator.
2423

2524

@@ -73,8 +72,7 @@ While developing in a branch, don't forget to pull from ``main`` regularly (at
7372
least daily) to make sure your work is compatible with other recent changes.
7473

7574
When you're ready to merge your branch into the ``main`` branch, create a pull request
76-
("PR") in the rail repository you cloned from. GitHub has instructions
77-
`here <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request>`_.
75+
("PR") in the rail repository you cloned from. `GitHub has instructions <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request>`_.
7876

7977
Several continuous integration checks will be performed for new pull requests.
8078
If any of these automatic processes find issues with the code, you should address
@@ -133,8 +131,8 @@ We follow the `pep8 <https://peps.python.org/pep-0008/#descriptive-naming-styles
133131
recommendations for naming new modules and ``RailStage`` classes within them.
134132

135133

136-
Modules
137-
-------
134+
Modules Names
135+
-------------
138136

139137
Modules should use all lowercase, with underscores where it aids the readability
140138
of the module name.
@@ -148,8 +146,8 @@ It's good for the module name to specify the source of the implementation of a p
148146
Note that these names should not be identical to the name of the package the algorithm came from, to avoid introducing namespace collisions for users who have imported the original package as well, i.e. ``pzflow_nf`` is a safer name than ``pzflow``.
149147

150148

151-
Stages
152-
------
149+
Stage Names
150+
-----------
153151

154152
RailStages are python classes and so should use the CapWords convention. All
155153
rail stages using the same algorithm should use the same short, descriptive
@@ -170,6 +168,32 @@ Possible suffixes include:
170168
* Degrader
171169
* Evaluator
172170

171+
172+
173+
RAIL Documentation
174+
==================
175+
176+
All of the documentation on this site is built as part of the
177+
`RAIL Package <https://github.com/lsstdesc/rail>`_, and the
178+
configuration and skeleton for the documenation live in the
179+
`rail/docs` directory.
180+
181+
The documation skeleton is setup to work with whatever rail
182+
packages are installed, e.g., if you are just working on one
183+
of the algorithms, you can just install that algorithm in
184+
addition to `rail_base` and `rail` and when you generate the
185+
docs you will just get the docs for `rail_base` and that package.
186+
187+
The documentation uses `sphinx
188+
<https://www.sphinx-doc.org/en/master/>`_
189+
to automatically generate some content from the source code,
190+
this requires being very careful with docstring formatting. The rail_base package is pretty good about using the numpy docstring style, so I think we should migrate things towards that: https://numpydoc.readthedocs.io/en/latest/format.html
191+
the documentation uses some python cleverness to find all the rail code in your current python environment, this lives in: rail_base/src/rail/core/introspection.py
192+
the rail package is linked to readthedocs so that anytime we push to main it will get pulled over to readthedocs.
193+
194+
195+
196+
173197

174198
Contribution Types
175199
==================

0 commit comments

Comments
 (0)