Skip to content

Commit 8e90cfb

Browse files
authored
Merge pull request #14 from hdmf-dev/update_docs
Copy and adjust docs files from nwb-schema
2 parents c468f3c + ab458bc commit 8e90cfb

17 files changed

+1021
-16
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Sphinx documentation
7+
docs/_build/
8+
9+
# Autogenerated Sphinx sources
10+
docs/source/_format_auto_docs/
11+
12+
# Jupyter Notebook
13+
.ipynb_checkpoints
14+
15+
#PyCharm
16+
.idea/

Legal.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
“hdmf-common-schema” Copyright (c) 2019-2020, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
2+
3+
If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Innovation & Partnerships Office at [email protected].
4+
5+
NOTICE. This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit other to do so.

docs/Makefile

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXAPIDOC = sphinx-apidoc
8+
PAPER =
9+
BUILDDIR = _build
10+
RSTDIR = source
11+
CONFDIR = $(PWD)/$(RSTDIR)
12+
13+
# Internal variables.
14+
PAPEROPT_a4 = -D latex_paper_size=a4
15+
PAPEROPT_letter = -D latex_paper_size=letter
16+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(RSTDIR)
17+
# the i18n builder cannot share the environment and doctrees with the others
18+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19+
20+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext fulldoc allclean
21+
22+
help:
23+
@echo "To update documentation sources from the format specification please use \`make apidoc'"
24+
@echo ""
25+
@echo "To build the documenation please use \`make <target>' where <target> is one of"
26+
@echo " fulldoc to rebuild the apidoc, html, and latexpdf documents all at once"
27+
@echo " html to make standalone HTML files"
28+
@echo " dirhtml to make HTML files named index.html in directories"
29+
@echo " singlehtml to make a single large HTML file"
30+
@echo " pickle to make pickle files"
31+
@echo " json to make JSON files"
32+
@echo " htmlhelp to make HTML files and a HTML help project"
33+
@echo " qthelp to make HTML files and a qthelp project"
34+
@echo " devhelp to make HTML files and a Devhelp project"
35+
@echo " epub to make an epub"
36+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
37+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
38+
@echo " text to make text files"
39+
@echo " man to make manual pages"
40+
@echo " texinfo to make Texinfo files"
41+
@echo " info to make Texinfo files and run them through makeinfo"
42+
@echo " gettext to make PO message catalogs"
43+
@echo " changes to make an overview of all changed/added/deprecated items"
44+
@echo " linkcheck to check all external links for integrity"
45+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
46+
@echo " apidoc to build RST from source code"
47+
@echo " clean to clean all documents built by Sphinx in _build"
48+
@echo " allclean to clean all autogenerated documents both from Sphinx and apidoc"
49+
50+
allclean:
51+
$(MAKE) clean
52+
-rm $(RSTDIR)/_format_auto_docs/*.png
53+
-rm $(RSTDIR)/_format_auto_docs/*.pdf
54+
-rm $(RSTDIR)/_format_auto_docs/*.rst
55+
-rm $(RSTDIR)/_format_auto_docs/*.inc
56+
-rm $(RSTDIR)/_format_auto_docs/git_hash.txt
57+
58+
clean:
59+
-rm -rf $(BUILDDIR)/*
60+
61+
html:
62+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
63+
@echo
64+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
65+
66+
dirhtml:
67+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
68+
@echo
69+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
70+
71+
singlehtml:
72+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
73+
@echo
74+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
75+
76+
pickle:
77+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
78+
@echo
79+
@echo "Build finished; now you can process the pickle files."
80+
81+
json:
82+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
83+
@echo
84+
@echo "Build finished; now you can process the JSON files."
85+
86+
htmlhelp:
87+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
88+
@echo
89+
@echo "Build finished; now you can run HTML Help Workshop with the" \
90+
".hhp project file in $(BUILDDIR)/htmlhelp."
91+
92+
qthelp:
93+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
94+
@echo
95+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
96+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
97+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/sample.qhcp"
98+
@echo "To view the help file:"
99+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc"
100+
101+
devhelp:
102+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
103+
@echo
104+
@echo "Build finished."
105+
@echo "To view the help file:"
106+
@echo "# mkdir -p $$HOME/.local/share/devhelp/sample"
107+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample"
108+
@echo "# devhelp"
109+
110+
epub:
111+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
112+
@echo
113+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
114+
115+
latex:
116+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
117+
@echo
118+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
119+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
120+
"(use \`make latexpdf' here to do that automatically)."
121+
122+
latexpdf:
123+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
124+
@echo "Running LaTeX files through pdflatex..."
125+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
126+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
127+
128+
text:
129+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
130+
@echo
131+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
132+
133+
man:
134+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
135+
@echo
136+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
137+
138+
texinfo:
139+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
140+
@echo
141+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
142+
@echo "Run \`make' in that directory to run these through makeinfo" \
143+
"(use \`make info' here to do that automatically)."
144+
145+
info:
146+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
147+
@echo "Running Texinfo files through makeinfo..."
148+
make -C $(BUILDDIR)/texinfo info
149+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
150+
151+
gettext:
152+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
153+
@echo
154+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
155+
156+
changes:
157+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
158+
@echo
159+
@echo "The overview file is in $(BUILDDIR)/changes."
160+
161+
linkcheck:
162+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
163+
@echo
164+
@echo "Link check complete; look for any errors in the above output " \
165+
"or in $(BUILDDIR)/linkcheck/output.txt."
166+
167+
doctest:
168+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
169+
@echo "Testing of doctests in the sources finished, look at the " \
170+
"results in $(BUILDDIR)/doctest/output.txt."
171+
172+
apidoc:
173+
PYTHONPATH=$(CONFDIR):$(PYTHONPATH) hdmf_generate_format_docs
174+
@echo
175+
@echo "Generate rst source files from HDMF-common spec."
176+
177+
fulldoc:
178+
$(MAKE) allclean
179+
@echo
180+
@echo "Rebuilding apidoc, html, latexpdf"
181+
$(MAKE) apidoc
182+
$(MAKE) html
183+
$(MAKE) latexpdf

docs/Readme.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
**Overview**
2+
3+
The HDMF-common specification documentation uses Sphinx [http://www.sphinx-doc.org/en/stable/index.html](http://www.sphinx-doc.org/en/stable/index.html)
4+
5+
**Prerequisites**
6+
7+
```pip install hdmf-docutils```
8+
9+
**Rebuilding All**
10+
11+
To rebuild the full documentation in html, latex, and PDF simply run:
12+
13+
```make fulldoc```
14+
15+
This is a convenience function that is equivalent to:
16+
17+
```
18+
make allclean
19+
make apidoc
20+
make html
21+
make latexpdf
22+
```
23+
24+
**Generating the format documentation from the format spec**
25+
26+
The format documentation is auto-generated from the format specification (YAML/JSON) sources via:
27+
28+
```make apidoc```
29+
30+
This will invoke the ``hdmf_generate_format_docs`` executable provided by ``hdmf-docutils`` package to automatically generate a series of .rst, .png, and .pdf files that are stored in the folder ```source/_format_auto_docs```. The generated .rst files are included in ```source/format.rst``` and the png and pdf files are used as figures in the autogenerated docs. The folder ```source/format_auto_docs``` is reserved for autogenerated files, i.e., files in the folder should not be added or edited by hand as they will be deleted and rebuilt during the full build of the documentation.
31+
32+
By default the Sphinx configuration is setup to always regenerate the sources whenever the docs are being built (see next section). This behavior can be customized via the ```spec_doc_rebuild_always``` parameter in ```source/conf.py```
33+
34+
**Building a specific document type**
35+
36+
To build the documentation simply:
37+
38+
```make <doctype>```
39+
40+
where ```<doctype>``` is, e.g., ```latexpdf```, ```html```, ```singlehtml``` or ```man```. For a complete list of supported doc-types see:
41+
42+
```make help```
43+
44+
**Cleaning up**
45+
46+
```make clean``` cleans up all builds of the documentation located in ```_build```.
47+
48+
```make allclean``` cleans up all builds of the documentation located in ```_build``` as wellas all autogenerated sources stored in ```source/format_auto_docs```.
49+
50+
**Configuration**
51+
52+
The build of the documentation can be customized via a broad range of Sphinx options in:
53+
54+
```source/conf_doc_autogen.py```
55+
56+
In addition to standard Sphinx options, there are a number of additional options used to customize the content and structure of the autogenerated documents, e.g.:
57+
58+
* ```spec_show_yaml_src``` Boolean indicating whether the YAML sources should be included for the different neurodata types
59+
* ```spec_show_json_src``` Boolean indicating whether the JSON sources should be included for the different neurodata types
60+
* ```spec_generate_src_file``` Boolen indicating whether the YAML/JSON sources of the neurodata_types should be rendered in a separate section (True) or in the same location as the main documentation
61+
* ```spec_show_hierarchy_plots ``` Boolean indicating whether we should generate and show figures of the hierachy defined by the specifications as part of the documentation
62+
* ```spec_file_per_type``` Boolean indicating whether we should generate separate .inc reStructuredText for each neurodata_type (True)
63+
or should all text be added to the main file (False)
64+
* ```spec_show_subgroups_in_tables``` Should subgroups of the main groups be renderd in the table as well. Usually this is disabled since groups are rendered as separte sections in the tex
65+
* ```spec_appreviate_main_object_doc_in_tables``` Appreviate the documentation of the main object for which a table is rendered in the table. This is commonly set to True as doc of the main object is alrready rendered as the main intro for the section describing the object
66+
* ```spec_show_title_for_tables``` Add a title for the table showing the specifications.
67+
* ```spec_show_subgroups_in_seperate_table``` Should top-level subgroups be listed in a seperate table or as part of the main dataset and attributes table
68+
* ```spec_table_depth_char``` Char to be used as prefix to indicate the depth of an object in the specification hierarchy. NOTE: The char used should be supported by LaTeX.
69+
* ```spec_add_latex_clearpage_after_ndt_sections``` Add a LaTeX clearpage after each main section describing a neurodata_type. This helps in LaTeX to keep the ordering of figures, tables, and code blocks consistent in particular when the hierarchy_plots are included.
70+
* ```spec_resolve_type_inc``` Resolve includes to always show the full list of objects that are part of a type (True) or to show only the parts that are actually new to a current type while only linking to base types (False)
71+
72+
In addition, the location of the input format specification can be customized as follows:
73+
74+
75+
* ```spec_input_spec_dir``` Directory where the YAML files for the namespace to be documented are located
76+
* ```spec_input_namespace_filename``` Name of the YAML (or JSON) file with the specification of the Namespace to be documented
77+
* ```spec_input_default_namespace``` Name of the default namespace in the file
78+
79+
Finally, the name and location of output files can be customized as follows:
80+
81+
82+
* ```spec_output_dir``` Directory where the autogenerated files should be stored
83+
* ```spec_output_master_filename``` Name of the master rst file that includes all the autogenerated docs
84+
* ```spec_output_doc_filename``` Name of the file where the main documentation goes
85+
* ```spec_output_src_filename``` Name of the file where the sources of the format spec go. NOTE: This file is only generated if spec_generate_src_file is enabled
86+
* ```spec_output_doc_type_hierarchy_filename``` Name of the file containing the type hierarchy. (Included in spec_output_doc_filename)
87+
88+
To speed up the build of the format docs we can prevent the ``hdmf_generate_format_docs`` executable from regenerating the sources from YAML if the git-hash from the previous build is still current. This is controlled via the following options:
89+
90+
* ``spec_clean_output_dir_if_old_git_hash`` Clean up the output directory before we generate the source if the git hash is out of date
91+
92+
* ``spec_skip_doc_autogen_if_current_git_hash`` Do not rebuild the format sources if we have previously build the sources and the git hash matches
93+
94+
In the regular Sphinx ```source/conf.py``` file we can then also set:
95+
96+
* ```spec_doc_rebuild_always``` Boolean to define to always rebuild the source docs from YAML when doing a regular build of the sources (e.g., via ```make html```) even if the folder with the source files already exists

0 commit comments

Comments
 (0)