-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from izmalk/manual-docs-upd-deinit
[DOCPR-1022] Document manual workflow
- Loading branch information
Showing
5 changed files
with
138 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. _edit: | ||
|
||
Edit content | ||
============ | ||
|
||
The landing page is stored in the :file:`docs/index.rst` file | ||
while the rest of the pages are stored in the :file:`docs/content/` folder by default. | ||
|
||
The Navigation Menu structure is set by ``.. toctree::`` directives. These directives define the hierarchy of included content throughout the documentation. | ||
The :file:`index.rst` page's ``toctree`` block contains the top level Navigation Menu. | ||
|
||
To add a new page to the documentation: | ||
|
||
1. Create a new file in the `docs/content` folder. For example, to create the **Reference** page, create a document called :file:`reference.rst`, insert the following |RST|-formatted heading ``Reference`` at the beginning, and then save the file: | ||
|
||
.. code-block:: rest | ||
:caption: reStructuredText title example | ||
Reference | ||
========= | ||
If you prefer to use Markdown (MyST) syntax instead of |RST|, you can create a Markdown file. For example, :file:`reference.md` file with the following Markdown-formatted heading at the beginning: | ||
|
||
.. code-block:: markdown | ||
:caption: Markdown title example | ||
# Reference | ||
2. Add the new page to the Navigation Menu: open the :file:`index.rst` file or another file where you want to nest the new page; at the bottom of the file, locate the ``toctree`` directive and add a properly indented line containing the path (without a file extension) to the new file created in the first step. For example, ``content/reference``. | ||
|
||
The ``toctree`` block will now look like this: | ||
|
||
.. code-block:: rest | ||
.. toctree:: | ||
:hidden: | ||
:maxdepth: 2 | ||
/content/quickstart | ||
/content/setup | ||
/content/update | ||
/content/automatic_checks | ||
/content/examples | ||
/content/contributing | ||
/content/reference | ||
The documentation will now show the new page added to the navigation when rebuilt. | ||
|
||
By default, the page's title (the first heading in the file) is used for the Navigation Menu entry. You can overwrite a name of a Menu element by specifying it explicitly in the ``toctree`` block, for example: `Reference </content/reference>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,17 @@ | ||
.. _enable: | ||
|
||
Enable the starter pack | ||
======================= | ||
Copy the starter pack | ||
===================== | ||
|
||
You can use the starter pack to set up your documentation in one of the following ways: | ||
Make sure to copy all required starter pack files to initialise a new documentation set: | ||
|
||
- As a standalone documentation project in a new repository | ||
- In a dedicated documentation folder in an existing code repository | ||
#. Clone the `Starter pack <https://github.com/canonical/sphinx-docs-starter-pack>`_ repository locally. | ||
#. Copy the following folders and files from the starter pack temporary folder to the repository where you want your documentation, placing them at the same relative paths: | ||
|
||
The starter pack provides a shell script that updates and copies the starter pack files to the selected location. | ||
- :file:`docs` -- your documentation folder. Original content includes initial documentation pages (you are reading one of them) and internal Sphinx files | ||
- :file:`.readthedocs.yaml` -- the **Read the Docs** configuration file | ||
- :file:`.wokeignore` -- a list of exceptions for the inclusive language check | ||
- :file:`.github/workflows/*-checks.yml` -- documentation tests | ||
|
||
.. note:: | ||
The recommended way of setting up the starter pack is to use the initialisation script. | ||
This method is automatically tested for the two scenarios mentioned above. | ||
|
||
However, if you prefer to copy the files manually instead of running the script, this is also possible. | ||
Make sure to check the comments in the script in this case, because you will need to update the configuration in several files (in addition to copying the files to the correct locations). | ||
Also see :ref:`enable-behind-the-scenes`. | ||
|
||
|
||
Run the initialisation script | ||
----------------------------- | ||
|
||
The initialisation script will download all required files, update them, and copy them to the selected location. | ||
|
||
1. Download :file:`init.sh` from the starter pack repository. | ||
#. Put the script into the root folder of the Git repository in which you want to enable the starter pack. | ||
|
||
This can be a new, empty repository or your code repository. | ||
#. Make the script executable:: | ||
|
||
chmod u+x init.sh | ||
#. Run the script:: | ||
|
||
./init.sh | ||
#. When prompted, enter the installation directory: | ||
|
||
- For standalone repositories, enter a full stop (``.``). | ||
- For documentation in code repositories, enter the name of the documentation folder (for example, ``docs``). | ||
|
||
If the folder does not yet exist, it is created. | ||
If the folder exists already, some of its files might be overwritten by starter pack files, so make sure you have a backup. | ||
#. When prompted, specify if you'll be using ``.rst`` or ``.md`` | ||
#. Check the output for any warnings or errors. | ||
|
||
You can now delete the :file:`init.sh` file. | ||
|
||
.. _enable-behind-the-scenes: | ||
|
||
Behind the scenes | ||
----------------- | ||
|
||
We recommend using the initialisation script to enable the starter pack. | ||
Here's a summary of what it does: | ||
|
||
1. Prompt for the directory that will contain the documentation. | ||
#. Clone the starter pack repository into a temporary directory. | ||
#. Update several of the configuration files to adapt paths to the documentation directory. | ||
#. Create the documentation directory. | ||
#. Copy the starter pack files into the documentation directory. | ||
#. Move some required files into the root folder of the repository (the GitHub workflow file and a :file:`.wokeignore` file), unless they exist already. | ||
#. Remove the temporary directory. | ||
After copying the starter pack files to your repository, make sure to set the project's name and other configuration parameters in the :file:`docs/conf.py` :spellexception:`config file`. | ||
For more information on configuration parameters, see the :ref:`customise` page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,49 @@ | ||
.. _quickstart: | ||
|
||
================ | ||
Quickstart guide | ||
---------------- | ||
================ | ||
|
||
The following steps will guide you through setting up your documentation using the starter pack and building an initial set of documentation. | ||
This page contains a short guide on how to set up and use the starter pack. For more information, see the respective sections of the starter pack documentation: | ||
:ref:`setup`, :ref:`update`, :ref:`automatic-checks`. | ||
|
||
For more detailed information, see the other sections of the starter pack documentation. | ||
Initial setup | ||
============= | ||
|
||
1. Download the :file:`init.sh` file from the starter pack repository and place it into the directory where you want to set up your documentation. | ||
Clone the `Starter pack <https://github.com/canonical/sphinx-docs-starter-pack>`_ repository to a temporary local folder. | ||
|
||
#. Run the script and specify where you want the files for the documentation framework to be placed (either in the current directory or in a sub-directory). | ||
Your own documentation files will need to be placed in the same directory (or sub-directories of it) later. | ||
Copy the following folders and files preserving their paths from the starter pack to the repository you want your documentation to be: | ||
|
||
See :ref:`enable` for detailed information on what the script does. | ||
- :file:`docs` | ||
- :file:`.readthedocs.yaml` | ||
- :file:`.wokeignore` | ||
- :file:`.github/workflows/*-checks.yml` | ||
|
||
#. Enter the documentation folder (the folder you specified when running the script, such as :file:`docs/`) and build the documentation with the following command:: | ||
|
||
make run | ||
Build and run the local server | ||
============================== | ||
|
||
This command creates a virtual environment, installs the Python dependencies, builds the documentation, and serves it on :literalref:`http://127.0.0.1:8000/`. | ||
To build HTML documentation the prerequisites are: | ||
|
||
See :ref:`build` for detailed information on different commands for building and viewing the documentation. | ||
* ``make`` | ||
* ``python3`` | ||
* ``python3-venv`` | ||
* ``python3-pip`` | ||
|
||
#. Keep this session running to rebuild the documentation automatically whenever a file is saved, and open :literalref:`http://127.0.0.1:8000/` in a web browser to see the locally built and hosted HTML. | ||
In :file:`docs`, run:: | ||
|
||
#. To add a new page to the documentation, create a new document called :file:`reference.rst`, insert the following |RST|-formatted ``Reference`` heading, and then save the file: | ||
make run | ||
|
||
.. code-block:: rest | ||
This creates and activates a virtual environment in :file:`docs/.sphinx/venv`, builds the documentation and serves it at :literalref:`http://127.0.0.1:8000/`. | ||
|
||
Reference | ||
========= | ||
The server watches the source files, including :file:`docs/conf.py`, and rebuilds automatically on changes. | ||
|
||
.. note:: | ||
This Quickstart guide uses |RST|, but if you prefer to use Markdown, you can create a :file:`reference.md` file with the following content instead: | ||
Configure | ||
========= | ||
|
||
.. code-block:: Markdown | ||
Work through the settings in :file:`docs/conf.py`. Most parameters can be left with the default values as they can be changed later. | ||
|
||
# Reference | ||
Update content | ||
============== | ||
|
||
#. Open :file:`index.rst`. | ||
|
||
At the bottom of this file, add a 3-space-indented line containing ``Reference <reference>`` to the end of the ``toctree`` section, and then save the file. | ||
This is the navigation title for the new document and its filename without the extension. | ||
|
||
The ``toctree`` section will now look like this: | ||
|
||
.. code-block:: rest | ||
.. toctree:: | ||
:hidden: | ||
:maxdepth: 2 | ||
self | ||
Reference <reference> | ||
.. note:: | ||
You can leave out the navigation title to use the document title instead. | ||
This means that in this example, you could also just type ``reference`` instead of ``Reference <reference>``. | ||
|
||
#. Check :literalref:`http://127.0.0.1:8000/`. | ||
|
||
The documentation will now show **Reference** added to the navigation, and selecting the link in the navigation will open the new ``reference.rst`` document. | ||
|
||
See :ref:`guidance` for links to more detailed information about |RST| and Markdown/MyST. | ||
The landing page is :file:`docs/index.rst`. Other pages are under :file:`docs/content`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters