Skip to content

Commit 6cf973e

Browse files
authored
Merge pull request #11831 from IQSS/doc-contrib
Building guides: Python 3.10 required, try Docker first, custom titles, other tweaks
2 parents f1b4e24 + 54c0b72 commit 6cf973e

File tree

1 file changed

+46
-38
lines changed

1 file changed

+46
-38
lines changed

doc/sphinx-guides/source/contributor/documentation.md

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,76 +50,78 @@ If you would like to read more about the Dataverse's use of GitHub, please see t
5050

5151
## Building the Guides with Sphinx
5252

53-
While the "quick fix" technique shown above should work fine for minor changes, especially for larger changes, we recommend installing Sphinx on your computer or using a Sphinx Docker container to build the guides locally so you can get an accurate preview of your changes.
53+
While the "quick fix" technique shown above should work fine for minor changes, in many cases, you're going to want to preview changes locally before committing them.
5454

55-
In case you decide to use a Sphinx Docker container to build the guides, you can skip the next two installation sections, but you will need to have Docker installed.
55+
Before we worry about pushing changes to the code, let's make sure we can build the guides.
5656

57-
### Installing Sphinx
57+
Go to <https://github.com/IQSS/dataverse> and click "Code" and then follow the instructions to clone the code locally.
5858

59-
First, make a fork of <https://github.com/IQSS/dataverse> and clone your fork locally. Then change to the ``doc/sphinx-guides`` directory.
59+
### Docker
6060

61-
``cd doc/sphinx-guides``
61+
Install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
6262

63-
Create a Python virtual environment, activate it, then install dependencies:
63+
From a terminal, switch to the "dataverse" directory you just cloned. This is the root of the git repo.
6464

65-
``python3 -m venv venv``
65+
`cd dataverse`
6666

67-
``source venv/bin/activate``
67+
Then try running this command:
6868

69-
``pip install -r requirements.txt``
69+
`docker run -it --rm -v $(pwd):/docs sphinxdoc/sphinx:7.2.6 bash -c "cd doc/sphinx-guides && pip3 install -r requirements.txt && make html"`
7070

71-
### Installing GraphViz
71+
If all goes well, you should be able to open `doc/sphinx-guides/build/html/index.html` to see the guides you just built.
7272

73-
In some parts of the documentation, graphs are rendered as images using the Sphinx GraphViz extension.
73+
#### Docker with a Makefile
7474

75-
Building the guides requires the ``dot`` executable from GraphViz.
75+
Once you've confirmed you have Docker working, if you have [make](https://en.wikipedia.org/wiki/Make_(software)) installed, you can try the following commands:
7676

77-
This requires having [GraphViz](https://graphviz.org) installed and either having ``dot`` on the path or
78-
[adding options to the `make` call](https://groups.google.com/forum/#!topic/sphinx-users/yXgNey_0M3I).
77+
`make docs-html`
7978

80-
On a Mac we recommend installing GraphViz through [Homebrew](<https://brew.sh>). Once you have Homebrew installed and configured to work with your shell, you can type `brew install graphviz`.
79+
`make docs-pdf`
8180

82-
### Editing and Building the Guides
81+
`make docs-epub`
8382

84-
To edit the existing documentation:
83+
`make docs-all`
8584

86-
- Create a branch (see {ref}`how-to-make-a-pull-request`).
87-
- In ``doc/sphinx-guides/source`` you will find the .rst files that correspond to https://guides.dataverse.org.
88-
- Using your preferred text editor, open and edit the necessary files, or create new ones.
85+
### Sphinx Installed Locally
8986

90-
Once you are done, you can preview the changes by building the guides locally. As explained, you can build the guides with Sphinx locally installed, or with a Docker container.
87+
First, run `python --version` or `python3 --version` to determine the version of Python you have. If you don't have Python 3.10 or higher, you must upgrade.
9188

92-
#### Building the Guides with Sphinx Installed Locally
93-
94-
Open a terminal, change directories to `doc/sphinx-guides`, activate (or reactivate) your Python virtual environment, and build the guides.
89+
Next, change to the `doc/sphinx-guides` directory.
9590

9691
`cd doc/sphinx-guides`
9792

93+
Create a Python virtual environment, activate it, then install dependencies:
94+
95+
`python3 -m venv venv`
96+
9897
`source venv/bin/activate`
9998

100-
`make clean`
99+
`pip install -r requirements.txt`
101100

102-
`make html`
101+
Next, install [GraphViz](https://graphviz.org) because building the guides requires having the `dot` executable from GraphViz either on the path or passed [as an argument](https://groups.google.com/g/sphinx-users/c/yXgNey_0M3I/m/3T2NipFlBgAJ).
103102

104-
#### Building the Guides with a Sphinx Docker Container and a Makefile
103+
On a Mac we recommend installing GraphViz through [Homebrew](<https://brew.sh>). Once you have Homebrew installed and configured to work with your shell, you can type `brew install graphviz`.
105104

106-
We have added a Makefile to simplify the process of building the guides using a Docker container, you can use the following commands from the repository root:
105+
Finally, you can try building the guides with the following command.
107106

108-
- `make docs-html`
109-
- `make docs-pdf`
110-
- `make docs-epub`
111-
- `make docs-all`
107+
`make html`
112108

113-
#### Building the Guides with a Sphinx Docker Container and CLI
109+
If all goes well, you should be able to open `doc/sphinx-guides/build/html/index.html` to see the guides you just built.
114110

115-
If you want to build the guides using a Docker container, execute the following command in the repository root:
111+
## Editing, Building, and Previewing the Guides
116112

117-
`docker run -it --rm -v $(pwd):/docs sphinxdoc/sphinx:7.2.6 bash -c "cd doc/sphinx-guides && pip3 install -r requirements.txt && make html"`
113+
To edit the existing documentation:
118114

119-
#### Previewing the Guides
115+
- Create a branch (see {ref}`how-to-make-a-pull-request`).
116+
- In `doc/sphinx-guides/source` you will find the .rst or .md files that correspond to https://guides.dataverse.org.
117+
- Using your preferred text editor, open and edit the necessary files, or create new ones.
118+
119+
Once you are done, you can preview the changes by building the guides using one of the options above.
120120

121121
After Sphinx is done processing the files you should notice that the `html` folder in `doc/sphinx-guides/build` directory has been updated. You can click on the files in the `html` folder to preview the changes.
122122

123+
## Making a Pull Request
124+
123125
Now you can make a commit with the changes to your own fork in GitHub and submit a pull request. See {ref}`how-to-make-a-pull-request`.
124126

125127
## Writing Guidelines
@@ -153,16 +155,22 @@ If the page is written in Markdown (.md), use this form:
153155

154156
### Links
155157

156-
Getting links right with .rst files can be tricky.
158+
Getting links right can be tricky.
157159

158160
#### Custom Titles
159161

160-
You can use a custom title when linking to a document like this:
162+
In .rst files you can use a custom title when linking to a document like this:
161163

162164
:doc:`Custom title </api/intro>`
163165

164166
See also <https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html#the-doc-role>
165167

168+
In .md files, the same pattern can be used. Here's an example of using a custom title with a ref:
169+
170+
{ref}`Log in <account-log-in-options>`
171+
172+
See also <https://myst-parser.readthedocs.io/en/v0.16.1/syntax/syntax.html#targets-and-cross-referencing>
173+
166174
### Images
167175

168176
A good documentation is just like a website enhanced and upgraded by adding high quality and self-explanatory images. Often images depict a lot of written text in a simple manner. Within our Sphinx docs, you can add them in two ways: a) add a PNG image directly and include or b) use inline description languages like GraphViz (current only option).

0 commit comments

Comments
 (0)