- Start by first creating a fork of the repo. This will create a personal clone of the repository under your username.
- Make a local clone of your fork using
git clone https://github.com/<your-user-name>/hydrotoolson the command line. - Change directories your local copy using
cd hydrotoolsfrom the command line.- If you have not setup
gitbefore, you'll need to tellgityour name and email. To set these options globally usegit config --global user.name "Your Name", thengit config --global user.email "[email protected]". You can do this locally instead usinggit config --local.
- If you have not setup
- Create a new branch to add work to using
git checkout -b sphinx-docs. Now we can move onto the installation.
We recommend using a virtual environment. Use the virtual environment manager of choice, here we will use anaconda.
Sphinxfurothis is thesphinxtheme used.hydrotools
# Create virtual environment
conda create --name hydrotools-sphinx-docs python=3.8 -y
# activate the virtual environment
conda activate hydrotools-sphinx-docs
# Install dependencies. This assumes you are in the hydrotools root directory
pip install .
pip install Sphinx furoTo build the docs, it helpful to first know the process. All hydrotools
documentation is build using Sphinx. Its
helpful to note that Sphinx by default uses reStructured text its another markup
language like markdown. For Sphinx to know about code we want to add to
gh-pages, its necessary to create bindings so Sphinx can go and create
documentation automagically. Lastly, before pushing any changes to the fork, a small
amount of house keeping is required to adjust the bindings Sphinx generated.
Bindings are generated using sphinx-apidoc. The example below created bindings for
the nwm_client and outputs them in the docs/ directory.
# Create bindings without a table of contents (toc), include private modules (start with _)
# separate all modules into individual rst files, tell sphinx-apidoc that the
# package is a namespace style package, output the bindings in docs/, generate bindings
# for nwm_client, and ignore files that include the word test.
sphinx-apidoc --no-toc --private --separate --implicit-namespaces -o docs/ python/nwm_client/src/hydrotools "*test?*"After running this, a few files should appear in the docs/ directory. The one named
hydrotools.nwm_client.rst is the package level file, there should be other
appended with module names like hydrotools.nwm_client.nwm.rst for example. If
the subpackage only has one file, you may just see one new binding, that's okay.
Next, open the package level file, in this case hydrotools.nwm_client.rst.
The top should look something like the following:
evaluation\_tools.nwm\_client package
=====================================
Submodules
----------All that is required is the word package be replaced with subpackage, so
evaluation\_tools.nwm\_client subpackage.
Lastly, its required that the package level file be referenced in docs/index.rst. You do
this by simply adding the filename without the extension to list of other modules
under the .. toctree: header.
So, this:
.. toctree::
:hidden:
:maxdepth: 2
:caption: API:
hydrotools.nwis_client
hydrotools._restclientBecomes this:
.. toctree::
:hidden:
:maxdepth: 2
:caption: API:
hydrotools.nwis_client
hydrotools._restclient
hydrotools.nwm_clientTo check that the subpackage bindings were added to Sphinx, from the docs/
directory, run make html. This will build an html form of the documents. To view
them, navigate to and open docs/_build/html/index.html using your web browser of
choice.
Run git status to see which files have been added/modified/deleted. Use git add <filename> to add each added/modified file to the staging area. Next, use git commit -m "<type a human readable commit message>" to add a commit message. Lastly,
use git push origin <the-name-of-your-branch> to push your changes to the remote.
From here, you can navigate to your fork on GitHub.com and open a pull request to
request your changes be pulled into official repository.