|
1 |
| -# plotly.py-docs |
| 1 | +# Documentation of plotly.py |
| 2 | + |
| 3 | +## Introduction: structure and required packages |
| 4 | + |
| 5 | +The `doc` directory contains the source files of the documentation of plotly.py. |
| 6 | +It is composed of two parts: |
| 7 | + |
| 8 | +- inside the [`python/` directory](python), tutorials corresponding to https://plot.ly/python/ |
| 9 | +- inside the [`apidoc/` directory](apidoc), configuration files for generating |
| 10 | + the API reference documentation (hosted on https://plot.ly/python-api-reference/) |
| 11 | + |
| 12 | +Python packages required to build the doc are listed in |
| 13 | +[`requirements.txt`](requirements.txt) in the `doc` directory. |
| 14 | + |
| 15 | +## Tutorials (`python` directory) |
| 16 | + |
| 17 | +Each tutorial is a markdown (`.md`) file, which can be opened in the Jupyter |
| 18 | +notebook or in Jupyterlab by installing [jupytext](https://jupytext.readthedocs.io/en/latest/install.html). |
| 19 | + |
| 20 | +For small edits (e.g., correcting typos) to an existing tutorial, you can simply click on the "edit this |
| 21 | +page on Github" link at the top right of the page (e.g. clicking on this link |
| 22 | +on https://plot.ly/python/bar-charts/ will take you to |
| 23 | +https://github.com/plotly/plotly.py/edit/doc-prod/doc/python/bar-charts.md, |
| 24 | +where you can edit the page on Github). |
| 25 | + |
| 26 | +For more important edits where you need to run the notebook to check the output, |
| 27 | +clone the repository and setup an environment as described in the [main |
| 28 | +contributing notes](../contributing.md). If you're writing documentation at the |
| 29 | +same time as you are developing a feature, make sure to install with editable |
| 30 | +install (`pip install -e`, as described in [main |
| 31 | +contributing notes](../contributing.md)), so that you only need to restart |
| 32 | +the Jupyter kernel when you have changed the source code of the feature. |
| 33 | + |
| 34 | +### Branches |
| 35 | + |
| 36 | +Two different cases exist, whether you are documenting a feature already |
| 37 | +released, or which has just been included but not yet released. |
| 38 | + |
| 39 | +- Case of an already released feature: your changes can be deployed to the |
| 40 | + documentation website as soon as they have been merged, and you should start |
| 41 | + your branch off the `doc-prod` branch and open your pull request against this |
| 42 | + `doc-prod` branch. |
| 43 | +- Case of a new (not released yet) feature: start your branch / pull request |
| 44 | + against the `master` branch. `master` and `doc-prod` will be synchronized at |
| 45 | + release time, so that the documentation of the feature is only deployed when |
| 46 | + it is available in a released version of `plotly.py`. |
| 47 | + |
| 48 | +### Guidelines |
| 49 | + |
| 50 | +We try to write short, standalone and (almost) self-explaining examples. Most |
| 51 | +examples should focus on a single feature. |
| 52 | + |
| 53 | +Checklist |
| 54 | + |
| 55 | +- Each example should have a clear title (titles are used for the navigation |
| 56 | + bar and indexed by search engines) |
| 57 | +- Package imports should be called in the same cell as the example, so that it |
| 58 | + is possible to copy-paste a single cell to reproduce the example. |
| 59 | +- Variable names should be consistent with other examples, for example use |
| 60 | + `fig` for a `Figure` object, `df` for a pandas dataframe, etc. |
| 61 | +- Examples should not be too long to execute (typically < 10s), since the doc is |
| 62 | + built as part of the continuous integration (CI) process. Examples taking |
| 63 | + longer to execute should be discussed in a new issue to decide whether they |
| 64 | + can be accepted. |
| 65 | + |
| 66 | +### Build process |
| 67 | + |
| 68 | +Run `make` to build html pages for the tutorials. This uses `jupytext` to |
| 69 | +execute the notebooks and `nbconvert` to convert notebook files to static html |
| 70 | +pages. Note that the CI will build the doc, so you don't have to build it |
| 71 | +yourself, it is enough to check that the markdown file runs correctly in |
| 72 | +Jupyter. |
| 73 | + |
| 74 | +The output of the `Makefile` is stored by CI in the `built` branch of the `plotly.py-docs` repo which is then used by the `documentation` repo to generate https://plot.ly/python. |
| 75 | + |
| 76 | +## API reference documentation (`apidoc` directory) |
| 77 | + |
| 78 | +We use [sphinx](http://www.sphinx-doc.org/en/master/) and its [`autodoc` |
| 79 | +extension](http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) |
| 80 | +in order to generate the documentation of the API. Sphinx uses the [reST markup |
| 81 | +language](https://www.sphinx-doc.org/en/2.0/usage/restructuredtext/basics.html). |
| 82 | + |
| 83 | +Run `make html` inside `apidoc` to build the API doc in the `_build/html` |
| 84 | +directory. |
| 85 | + |
| 86 | +Lists of objects to be documented are found in files corresponding to |
| 87 | +submodules, such as [`plotly.express.rst`](plotly.express.rst). When a new |
| 88 | +object is added to the exposed API, it needs to be added to the corresponding |
| 89 | +file to appear in the API doc. |
| 90 | + |
| 91 | +Other files |
| 92 | + |
| 93 | +- `css` files are found in `_static` |
| 94 | +- Template files are found in `_templates`. `.rst` templates describe how the |
| 95 | + autodoc of the different objects should look like. |
2 | 96 |
|
3 |
| -Documentation repo for plotly.py v4 |
4 | 97 |
|
5 |
| -The output of the `Makefile` is stored by CI in the `built` branch of the `plotly.py-docs` repo which is then used by the `documentation` repo to generate https://plot.ly/python |
|
0 commit comments