-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Added documentation for using a pip requirements file. #3636
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
Changes from 5 commits
9130f38
e07be83
c3d2ddc
d2d4a1e
a4bb8e3
9bb0f28
6a66934
828ec8a
9938805
70f5625
648e6fd
235c8b6
d05bd73
7d793e4
46d543a
56c8f4c
d7c779a
53b87a4
8aa1da2
70cc65d
4bc7671
f662ce8
30f1291
4423781
382c593
a129799
ae6b6b5
6317e06
31db082
c5753a5
1b58bed
e9d0d2f
5e46cbd
0a4a287
72e5f38
a9239fd
43667a0
0e1112f
17be1c1
2950fda
354ab83
e7dbb2b
09f8282
1330fd3
2e38321
75511f5
40b2039
3332b6d
8afa88a
4a7cd3e
4f77d9f
9d1246f
0206825
7776b31
666bf42
f4acc80
2866ab0
c37dff0
1e5657d
bd68928
640960a
5814aef
16f3527
8d6efef
062bff6
e527b35
775b19f
ffd60da
62a261d
c7b5638
28cc7b6
68a056c
457ac62
29674ee
5d54966
b277d9b
5d3d153
66419d2
84ec88f
308879a
27d9ba3
902f63f
2c653e2
d0a2402
4aef502
4b00f3f
94339b8
c8df83f
dc7c295
fcde821
e4cb814
70d94c9
d4d3170
333e96a
fd6e385
ac1ca00
2d9aa53
230ec2b
4030334
e25acfa
4595830
4e3f9bd
78b5781
f4b9727
1334c3c
3ddc15e
d127ea5
2a7a113
4d4b128
5d1d8f0
e923c0c
3a67d11
b4ed4df
baa6b07
d0c6abb
8b0350f
1edd47a
cc18a75
761a2ca
32670cb
e38d16c
3b5cd7c
50f1e44
68f4ab6
0ee36aa
cca6a0a
8f2d59c
8a2a95e
e5facfe
fde9c8a
d918a0f
d16f365
f1dc3df
3306d3a
4015c03
74bbb3a
1db9bbd
50e7d4b
d30cc12
e73b266
689f6a2
167a8ef
587f853
7893451
673bfc7
24ee5e5
10c2bdf
5edf99f
ed5a1bd
2a79250
bd36494
25ac414
43de909
8e5cce2
233febf
7ac7dfc
b242b41
da56a7d
ded401e
3c674f0
c5d102a
2d6d2a0
f3c0c0a
d6a51a4
8a34d5e
7b8efe3
ca35951
4b3fd71
6d32b25
7125a88
dcd998b
5a39385
d8f603c
bed1828
735a633
f4e645d
f2ac3cc
adb5392
54cc39f
84aea29
53f4124
ca6bcd1
f10e745
4e43caf
af4e06d
2fd1958
4b28325
873108b
7aa6f4d
7f2d711
8835b8b
cb555d4
5a4503d
d2acfa2
25ef46e
d273e30
5e98ece
251945b
9be835a
c7c2e05
22fceec
0d78a94
31581e4
dc1159c
887c25b
ddda401
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
Using a Requirements File | ||
========================= | ||
|
||
The requirements file option is useful in the following scenarios: | ||
- You are using external packages, extensions, and themes that you need to include in your documentation project | ||
- You have enabled the install project in a virtual environment option, but your package's setup.py file is not in the root directory. | ||
- You have multiple python packages in your project and you wish to document them. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block of copy can be reduced. We probably don't need to outline any of the scenarios where you might need a requirements.txt, as this doesn't really help the user solve the problem of setting up a requirements file. We can give the reader less to parse by simply stating that requirements files are useful for specifying dependencies. |
||
|
||
----------------------------- | ||
Using a pip requirements file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This duplicates the top heading. I think it can safely be removed. |
||
----------------------------- | ||
|
||
Creating the requirements file | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
You are using external packages, extensions, and themes that you need to include in your documentation project | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This heading is very long and probably should probably be shorter. I realize the idea was to match the 3 cases outlined in the first section but perhaps something like "Supporting external packages, extensions, and themes" would work. |
||
--------------------------------------------------------------------------------------------------------------- | ||
|
||
Read the Docs supports adding specific functionality, and themes to tailor the behavior and appearance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comma here is unnecessary. |
||
of your project's documentation. This is done by specifying a list of the packages, extensions, themes, to be used, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "packages, extensions, themes, to be used," -> "packages, extensions, and themes to be used" |
||
and their versions, during the documentation build process. | ||
|
||
For example, one can specify which version of *Sphinx* to use, which theme they would like to use, | ||
what extensions they would like to add and so on. | ||
|
||
To do this, one can create a list of requirements and save it in a requirements file. | ||
|
||
Since *RTD* uses Python language to build the workflow which automatically converts and hosts your project's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "uses Python language" -> "uses the Python language" |
||
documentation, and uses various python packages for this, the requirments file is the same as any standard python project. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "requirments" -> "requirements" |
||
Read the Docs installs them in a virtual environment using pip, the standard python package manager. | ||
|
||
In-fact, it is helpful to think of your documentation on readthedocs as a sub-project written in python, | ||
within your main project's repo. | ||
|
||
To use the requirements file: | ||
Create a text file with a sensible name in the root directory of your documentation directory. For example:: | ||
|
||
docs/requirements.txt | ||
docs/requirements-docs.txt | ||
|
||
This is a standard python requirements file. If you know how to use that, this is the same thing. If not, read on. | ||
In this file, list all the packages (one package per line) that you require for building your documentation. | ||
Make sure to specify their appropriate version. | ||
|
||
For example, say you wish to only use Sphinx version 1.1.x and the sphinx_rtd_theme with a minimum version of 0.1.9. | ||
You are also using external extensions, for example, the napolean extension, (make sure to specify them in | ||
the extensions list in conf.py file), then your requirements file might look something like this: | ||
|
||
:: | ||
|
||
# <insert optional comment explaining why this package or version is a requirement> | ||
sphinx == 1.1.* | ||
sphinx_rtd_theme >= 0.1.9 | ||
sphinxcontrib-napolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think most of this content can be better served by leaning on the Python packaging resources to explain what a requirements file is, how to use it, and how to maintain a good file. What's important to readers here is how to make this work with RTD:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestions for |
||
|
||
|
||
You have enabled the install project in a virtual environment option, but your package's setup.py file is not in the root directory. | ||
--------------------------------------------------------------------------------------------------------------------------------------- | ||
OR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
-- | ||
You have multiple python packages in your project and you wish to document them. | ||
-------------------------------------------------------------------------------- | ||
|
||
If you enable the option to install your project in a virtual environment, RTD automatically uses | ||
your project's setup.py file to install the packages. For this to work, the ``setup.py`` file must be | ||
in the root directory of your project. | ||
|
||
However, if you want to place your packages at a different location from the project's root directory, | ||
or your project has multiple python packages that you wish to document, then you can create a requirements file | ||
and specify the relative paths to your packages inside that file. | ||
|
||
For example, if you want to keep your python package in the ``src/python`` directory, located at the root of your project, | ||
create a ``requirements.readthedocs.txt`` file in your project root pointing to this path. | ||
Make sure that the path to the packages' root directory is relative to the path of the ``requirements.readthedocs.txt`` file. | ||
|
||
So if the requirements file is at the project root:: | ||
|
||
/requirements.readthedocs.txt | ||
|
||
its content will be:: | ||
|
||
src/python/ | ||
|
||
If you want to put the requirements in the file:: | ||
|
||
requirements/readthedocs.txt | ||
|
||
its contents will be:: | ||
|
||
../python/ | ||
|
||
Also see :ref:`faq_document_package_not_at_root` | ||
|
||
Using the requirements file via the project admin's web interface | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Once the requirements file has been created; | ||
|
||
- Login to Read the Docs as project admin. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Login -> Log in also, "as project admin" can be dropped |
||
- Select the project from My Projects. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "My Projects" is actually not the same on readthedocs.com, so we shouldn't refer to it like that here. Generally, we would write this step as "Go to you project admin dashboard" |
||
- Go to ``Admin > Advanced Settings > Requirements file``. | ||
- Specify the path of the requirements file you just created. The path should be relative to the root directory of the documentation project. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. documentation project -> repository |
||
|
||
Using the requirements file via the YAML configuration file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a second level heading, this is very long. Consider a second level heading of |
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Documentation builds can be configured using a config.py file or using a YAML (.yml) file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't mention conf.py here, this is superfluous to our directions here. a YAML file -> readthedocs.yml file |
||
|
||
.. warning:: Using a YAML file to setup build config is a feature in a beta state. Please file an `issue`_ if you find anything malfunctioning. | ||
|
||
|
||
The YAML file should be named ``readthedocs.yml`` or ``.readthedocs.yml`` and should be located in the root directory of the project. In the file, you can add a section ``requirements_file``, where the path to the requirements file can be specified | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block is duplicating content from our existing content on using a readthedocs.yml file, you can just point there and save the reader some effort. |
||
|
||
.. code-block:: yaml | ||
|
||
requirements_file: requirements/readthedocs.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good block to explain here 👍 It might be good to just call the file |
||
|
||
|
||
.. _issue: : https://github.com/rtfd/readthedocs.org/issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this file now goes over a pip requirements file and a conda environment file, we can update the heading to "Specifying Project Dependencies" or something generic like that