2022-03-25 15:33:54 +00:00
# PyTorch-Lightning Docs
We are using Sphinx with Napoleon extension.
Moreover, we set Google style to follow with type convention.
- [Napoleon formatting with Google style ](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html )
- [ReStructured Text (reST) ](https://docs.pylonsproject.org/projects/docs-style-guide/ )
- [Paragraph-level markup ](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#paragraphs )
See following short example of a sample function taking one position string and optional
```python
from typing import Optional
def my_func(param_a: int, param_b: Optional[float] = None) -> str:
"""Sample function.
Args:
param_a: first parameter
param_b: second parameter
Return:
sum of both numbers
Example::
>>> my_func(1, 2)
3
Note:
If you want to add something.
"""
p = param_b if param_b else 0
return str(param_a + p)
```
## Building Docs
When updating the docs, make sure to build them first locally and visually inspect the html files in your browser for
formatting errors. In certain cases, a missing blank line or a wrong indent can lead to a broken layout.
Run these commands
```bash
git submodule update --init --recursive
2022-06-15 14:54:53 +00:00
make docs
2022-03-25 15:33:54 +00:00
```
and open `docs/build/html/index.html` in your browser.
2022-10-21 18:01:39 +00:00
When you send a PR the continuous integration will run tests and build the docs.
2022-03-25 15:33:54 +00:00
2022-07-17 18:48:10 +00:00
Notes:
2022-03-25 15:33:54 +00:00
2022-07-17 18:48:10 +00:00
- You need to have LaTeX installed for rendering math equations. You can for example install TeXLive with the necessary extras by doing one of the following:
- on Ubuntu (Linux) run `sudo apt-get update && sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures`
2022-03-25 15:33:54 +00:00
- use the [RTD docker image ](https://hub.docker.com/r/readthedocs/build )
2022-07-17 18:48:10 +00:00
- You need to have pandoc installed for rendering Jupyter Notebooks. On Ubuntu (Linux), you can run: `sudo apt-get install pandoc`
2022-03-28 12:35:59 +00:00
## Developing docs
When developing the docs, building docs can be VERY slow locally because of the notebook tutorials.
To speed this up, enable this flag in before building docs:
```bash
# builds notebooks which is slow
2023-08-21 18:22:21 +00:00
export FAST_DOCS_DEV=0
2022-03-28 12:35:59 +00:00
# fast notebook build which is fast
2023-08-21 18:22:21 +00:00
export FAST_DOCS_DEV=1
2022-03-28 12:35:59 +00:00
```
## docs CSS/theme
2022-11-03 19:33:54 +00:00
To change the CSS theme of the docs, go [here ](https://github.com/Lightning-AI/lightning_sphinx_theme ).
2022-03-28 12:35:59 +00:00
Apologies in advance... this is a bit complex to build and requires basic understanding of javascript/npm.