Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README to show how to edit the documentation #1122

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Contributing to Altair Documentation

Altair documentation is written in [reStructuredText](http://docutils.sourceforge.net/rst.html) and compiled into html pages using [Sphinx](http://www.sphinx-doc.org/en/master/). Contributing to the documentation requires some extra dependencies and we have some conventions and plugins that are used to help navigate the docs and generate great Altair visualizations.

## Building the Documentation locally

eitanlees marked this conversation as resolved.
Show resolved Hide resolved
Assuming you have followed all the steps for a [development install](../README.md#development-install), you will need to also install the dependencies for documentation listed in `docs/requirements.txt` and install altair locally from the branch you are updating:

```
cd altair
pip install -r requirements.txt
pip install -e . # See Altair Readme for further information about installing Altair for development.
pip install -r doc/requirements.txt # Documentation install
```
In addition, the sphinx documentation builder needs access to Selenium to support generating images of sample visualizations. You may have selenium already installed but if you do not it can also be installed via pip but is not in the requirements file because of its size and dependencies.

```
pip install selenium
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried doing a fresh install and I had to run

pip install recommonmark

as well to make things work. Should recommonmark be added to doc/requirements.txt? @jakevdp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think recommonmark is part of requirements_dev.txt. We should probably either add pip install requirements_dev.txt to the list of steps to follow, or add the sphinx-related requirements to doc/requirements.txt

One you have all the dependencies, you can build the documentation using various commands defined in the Makefile. From the `doc` folder, you can use `make help` to see all of the available commands which control the type of documentation you want to generate:

```
$ make help

Please use `make <target>' where <target> is one of
html to make standalone HTML files
dirhtml to make HTML files named index.html in directories
singlehtml to make a single large HTML file
pickle to make pickle files
json to make JSON files
htmlhelp to make HTML files and a HTML help project
qthelp to make HTML files and a qthelp project
applehelp to make an Apple Help Book
devhelp to make HTML files and a Devhelp project
epub to make an epub
epub3 to make an epub3
latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
latexpdf to make LaTeX files and run them through pdflatex
latexpdfja to make LaTeX files and run them through platex/dvipdfmx
text to make text files
man to make manual pages
texinfo to make Texinfo files
info to make Texinfo files and run them through makeinfo
gettext to make PO message catalogs
changes to make an overview of all changed/added/deprecated items
xml to make Docutils-native XML files
pseudoxml to make pseudoxml-XML files for display purposes
linkcheck to check all external links for integrity
doctest to run all doctests embedded in the documentation (if enabled)
coverage to run coverage check of the documentation (if enabled)
dummy to check syntax errors of document sources

```
For most updates, run `make html` and the documentation will generate in a sub folder `_build`. You can open `_build/html/index.html` to view the documenation as local static files which should give you a good preview of how any updates will look. Even better, use the command below to serve the static files and you will be able to navigate the whole documentation website.

```
cd doc/_buld/_html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_buld should be _build

python -m http.server # python 3 required
```

## Documentation Conventions

**Adding Examples**

Examples are added to the folders `altair/vegalite/v2/examples` folder. To add an example, save a python file with your plot and a header consisting of a reStructuredText docstring at the top of the file including the title of the example following the docstring and a one line python comment with the category that your example belongs. Here is the format of a example header:

```
"""
Name of Your Plot
-----------------

A really good description of the example
"""
# category: case studies
import altair as alt
from vega_datasets import data

# more plot code
```
With this convention, your example will build automatically and be placed on the gallery page.

**Updating the User Guide**

When updating the user guide the following conventions are helpful:

* Add the directive ``.. currentmodule:: altair`` somewhere near the top of your documentation page so that you inform the renderer how to link to docstrings in the classes and functions.
* When referring to an Altair class or function preface it with ``:class:`` or ``:func:`` and the rendering engine will automatically link it to the appropriate section in the API reference.
* Link to examples using the following syntax
```
:ref:`gallery_chart_to_link_to`
```
* Link to other parts of the user guide with
```
:ref:`user-guide-filename`
```



1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ jinja2
numpydoc
pillow
sphinx_rtd_theme
recommonmark