- Clone and Navigate the repo on your computer
- Build Locally the HTML documentation
- The Pipeline (optional)
- Style guide
- Prereq's to build a PDF version (optional)
If you make it here, it means you have access right to the How-To git repo. Thus you may "clone" it somewhere on your computer (like this. This will copy all files from the server onto your computer.
You may notice that the documentation in itself (the text) is located in the folders from cdm till webui. All the rest are actually configuration and support folders and files.
All aimms docs repos build the same way: with uv and the versions pinned in
pyproject.toml (Sphinx 8, sphinx-aimms-theme 1.x). The CI pipeline uses exactly the same setup, so what
builds here builds there.
One-time setup
- Install uv:
winget install astral-sh.uvon Windows, orcurl -LsSf https://astral.sh/uv/install.sh | shon macOS and Linux. - Run
uv sync. It creates a.venvfolder with Python 3.11 and the exact packages ofuv.lock.
Build
uv run sphinx-build -b html . _build/html
Open _build/html/index.html in your browser. The pipeline runs the same command with -W --keep-going,
which turns every warning into an error: run uv run sphinx-build -W --keep-going -b html . _build/html
before you push.
Live preview: rebuilds and refreshes the browser each time you save a file.
uv run --group dev sphinx-autobuild . _build/html
Spell check: uv run sphinx-build -b spelling . _build/spelling. It needs the enchant library: included
on Windows, sudo apt install libenchant-2-2 on Ubuntu, brew install enchant on macOS.
Try a theme change before it is released: in the sphinx-aimms-theme repo, run
scripts\build-all-local.ps1 -Sites documentation. It builds this repo with the theme from your folder and
changes nothing here.
File names are case sensitive on Linux (the pipeline) but not on Windows, and a title underline must be at least as long as the title.
💡1: GitLab CI is following exactly the same process when building the documentation in the pipeline. This is defined in the .gitlab-ci.yml file. More details below
⚠️ 2: When pushing to the master branch only, the repo is built and pushed (merged) to documentation.aimms.com.
⚠️ 3: If any warning is raised on gitlab, the pipeline fails
After installing all the above requirements, please go to the location of your previously cloned documentation folder:
- Open a console prompt from this location, using
ATL+Dand typingcmdin the URL of your file explorer (Windows) - run
uv run sphinx-build -b spelling . _build/spelling(depending on you python this could be justpyorpythoninstead ofpython3; the first time, it may take some time, around 20 secs. progress is shown in your console).
Click me to show more info on console output 👇
- The console will log information on processing the spell checks. If any errors were encountered, you will find the
WARNING: Found X misspelled wordsline at the end of the log (where X is the number of errors encountered). - Scroll through the console until you find a line similar to
[..]\aimms-how-to\Articles\12\12-generate-random-numbers.rst:10: Spell check: disribution: [..] disribution [..] - This identifies the files with errors (in the example above 12-generate-random-numbers.rst), the line with the error (in the example above line 10) and the spell error (in the example above disribution)
- Sphinx will also create files with information on the spelling errors in the _build/spelling folder. Each failed rst file will have a corresponding spelling file.
- Be aware that CI/CD will only allow deploy if the spelling presents no errors/warnings.
- For reasons unkown, the spellcheck in gitlab (Linux environment) and on your local environment (probably Windwos) differs. In this case, you could get a clean check locally but not in the deploy process.
Every push to gitlab remote will run a pipeline. This pipeline first "Test" stage contains 3 different jobs as defined in .gitlab-ci.yml
| job name | description | condition |
|---|---|---|
build |
builds the docs using the latest sphinx version | ❌ If any warning is raised, the job and pipeline fails |
linkcheck |
checks every external link and anchor | |
spellcheck |
checks the spelling of every word | ❌ If any spelling is broken the job and pipeline fails |
If build fails on gitlab, but not locally, what should I do ? 👇
- look at the error/warning in the pipeline
- Upgrade your sphinx version and sphinx-aimms-theme version (
python -mpip --upgrade sphinx) - Linux filenames are case sensitive. Double check
If linkcheck fails on gitlab, but not locally, what should I do ? 👇
- if
buildalso fails, go to fixbuildfirst - look at the error/warning in the pipeline
- fix your broken link
- fix expired link, cause website no more reachable - Thanks for your help !
- Fix links locally using
make linkcheckorpython -msphinx -b linkcheck . _build/html - upgrade your sphinx version and sphinx-aimms-theme version (
python -mpip --upgrade sphinx sphinx-aimms-theme) - re-run the job in gitlab: some links might be temporarily not reachable
- If there is a link you want to ignore, put it
``example.com``
If spellcheck fails on gitlab, what should I do ? 👇
- look at the error/warning in the pipeline
- fix your spelling errors
- upgrade your sphinx version, sphinx spelling and sphinx-aimms-theme version (
python -mpip --upgrade sphinx sphinxcontrib.spelling sphinx-aimms-theme) - If there is a word you want to ignore, include the following directive in your article
.. spelling::
word1
word2
When pushing to the master branch
A push to master will run the pipeline and, if the Test stage is successful, it will copy the docs to documentation.aimms.com
If the pipeline fails, no copy will happen, thus website stays unchanged
Notes
- If there is a link you want to ignore, put it
``example.com``
Guidelines
-
PUBLISHING PROCESS - Create a Create a new branch for editing, and merge to develop branch when ready. It will be reviewed and published weekly. Please don't work in the master branch except in urgent cases (use your judgment).
-
IMAGES - When using screenshots, leave plenty of space around the area you want to show so the image can be edited and edges can be beautified. Use markup sparingly.
-
IMAGE LOCATION - Keep icons in the icon folder (they can be reused for many docs). Specific images should be in their own
imagesfolder in the numbered folder for that article, egArticles/233/images. -
FILE NAME CONVENTIONS - Use the Gitlab ticket number for the "id number" of your article and give it a short but descriptive file name. (Occasionally there can be more than one article under the same ticket number, but generally try to make a new ticket for each article.)
-
RST CONVENTIONS - Always follow the same code conventions for headings, images, etc. The code is flexible, but we want docs to be consistent.
-
LINKING TO ARBITRARY ANCHORS - Titles may change, headings may change. Avoid link to headings by their title, instead create references (anchors) in the code using :ref: - if the title of a heading changes, links in other docs won't be broken.
-
LINKING TO OTHER FILES - Use :doc: to link to other files in the same repo. It will automatically pull the up-to-date title.
-
LINKING TO FUNCTION REFERENCE - Use
:aimms:set:AllIdentifiersor `:any:`AllIdentifiers. This will create a link to the documentation for that function.
Quick reference
== Title (level 1) marker
-- Heading (level 2) marker
^^ Subheading (level 3) marker
.. Commented text
.. code-block:: aimms
*Italics*
**Bold**
``Monospace font``
#. Numbered list item
* Unordered list item
`External Link <www.url.com>`_
See also: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
Useful directives and roles in reST
Table of contents or index
.. toctree::
Use the sub-options :max-depth: or :titlesonly: appropriately, otherwise all sub-headings will show up in the table of contents leading to a long long list. Below two are equivalent.
.. toctree::
:maxdepth: 1
.. toctree::
:titlesonly:
Image
.. image:: /relativeFilePath/image.png
http://docutils.sourceforge.net/docs/ref/rst/directives.html#image
Code blocks, numbered
.. code-block::
:linenos:
Substitution
Can be useful for images, but any object or text string you may want to single-source for use in multiple docs.
Name the substitution in the header
.. |image-name| image:: /Images/image-name.png
Call the substitution in the document
|image-name|
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions
Download
Add a downloadable file to your page
:download:`this example script <downloads/example.py>`.
Relative file path
The given filename is usually relative to the current file. (../ represents go up a level, ../../ represents go up two levels, etc.)
http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#referencing-downloadable-files
Relative link
To link to another reST file in the same repo, you can use the :doc: role
:doc:`file-name`
or
:doc:`../file-name`
The link displays the title within the given document, or specify text to display explicitly
:doc:`explicit title <filePath/file-name>`
http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-documents
Cross-reference
Like an anchor, but can be referenced by name from any other doc in the repo by name (no file path needed). Used above a section header.
Name the anchor
.. _my-reference-label:
Section to cross-reference
--------------------------
This is the text of the section.
Refer to the anchor
See :ref:`my-reference-label`.
http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-ref
Include
Use this to add contents of an entire file in the repo to your document as a snippet. (We use this in How-to for the feedback form at the bottom.)
.. include:: inclusion.txt
http://docutils.sourceforge.net/docs/ref/rst/directives.html#include
You can use the make latexpdf command to locally create a .pdf from the .rst source files.
First, make sure you installed Latex - https://miktex.org/howto/install-miktex
Then, to get the AIMMS code to look right, you need to run this:
python -m pip install aimms-pygments-style
This will install an extension enabling latex to find the AIMMS style sheet define in the following open source repo https://gitlab.com/ArthurdHerbemont/aimms-pygments-style. Please contribute if you think you can improve it ! :)
