This guide aims to help documentation writers configure their local environment so they may contribute how-to guides to the ContraxSuite documentation corpus. ContraxSuite uses Sphinx to generate static documentation pages.
- ContraxSuite Sphinx Documentation
- Table of Contents
- Sphinx
- Assumptions
- Downloading the Documentation
- Configuring Virtual Environments
- Configuring Visual Studio Code
- Installing Sphinx
- Editing and Adding Files
- Adding Tables
- Developers Only: Attaching Django to Sphinx
- Committing Changes
- File Organization
- Resources
- Style Guide
- Work in Progress
Sphinx is a tool that makes it easy to create intelligent and beautiful documentation, written by Georg Brandl and licensed under the BSD license. It was originally created for the Python documentation, and it has excellent facilities for the documentation of software projects in a range of languages.
Source: sphinx-doc
The Sphinx-generated HTML pages will host the following information:
- ContraxSuite installation and configuration directions
- User guides
- Supplementatal development guides
- Django ORM documentation
Documentation writers must have the following software installed:
Please install these programs using the above hyperlinks if you have not done so already.
Note: While a documentation writer can respectively substitute Anaconda, GitHub Desktop, and VS Code with pip, git, and any other text editor, this guide largely assumes the former.
With GitHub Desktop
Screenshots coming!
- Clone the lexpredict-contraxsuite-services repository. (Help)
- Switch to the CS-4402 branch. (Help)
With git
in a terminal shell
- Clone the lexpredict-contraxsuite-services repository.
git clone https://github.com/LexPredict/lexpredict-contraxsuite-services.git
- Switch to the CS-4402 branch.
git checkout CS-4402
With Anaconda
- Open Anaconda Navigator.
- Select "Environments" on the left-hand side.
- At the bottom of the screen, click "Create".
- Name the new virtual environment something like
lexpredict_env
and make sure to use Python 3.6.
With Python 3.6's venv
python3 -m venv /path/to/new/virtual/environment
- Open Visual Studio Code.
- Install the following extensions (Help):
-
Choose your Python virtual environmentment using the Python extension.
-
File > Open Folder...
and navigate to thelexpredict-contraxsuite-services/documentation/docs
directory. -
In VS Code's File Explorer, open the
source
directory. -
Single-click the
conf.py
file. -
Running along the bottom of the VS Code window is the Status Bar. You should see text with "Python ... 64-bit" in the bottom bar.
-
Click that text and select the correct virtual environment using the modal window.
Not working? Here's an alternative way:
Ctrl-Shift-P
to open the Command Palette.- Type "Python: Select Interpreter".
- Select the correct virtual environment using the modal window.
-
-
Set Command Prompt as your default shell.
-
Terminal > New Terminal
-
In the terminal panel's menu bar, use the drop-down menu to "Select Default Shell"
-
Select "Command Prompt" using the modal window.
-
Close the Terminal Panel.
Not working? Here's an alternative way:
Ctrl-Shift-P
to open the Command Palette.- Type "Terminal: Select Default Shell".
- Select "Command Prompt" using the modal window.
-
-
Get to know the general layout of VS Code.
- The left-hand bar featuring a handful of glyphs is known as the "Activity Bar". There you can find file explorer, search menu, Git changes, and the extensions manager.
- A terminal panel can be opened using
Terminal > New Terminal
. The terminal panel can be docked on either the right-hand side or the bottom; simply right-click the panel's bar. - Markdown documents can be previewed by pressing
Ctrl-K V
or by clicking the dedicated preview button.
With Anaconda
- Open Anaconda Navigator
- Select "Environments" on the left-hand side.
- Toggle the drop-down menu from "Installed" to "All".
- Using the search bar, search for and install the packages listed in
requirements.txt
into yourlexpredict_env
virtual environment.
WARNING: Main project virtual env is used for generating docs during the CI build process. Please synchronize contraxsuite_services/deploy/base/python-requirements-all.txt with requirements.txt in the docs dir if making any changes in them.
With VS Code's Terminal
- Open Visual Studio Code.
File > Open Folder...
and navigate to thelexpredict-contraxsuite-services/documentation/docs
directory.- Select your LexPredict/ContraxSuite Python virtual environment.
- Open a new terminal panel.
- Type the following and press
Enter
WARNING: Main project virtual env is used for generating docs during the CI build process. Please synchronize contraxsuite_services/deploy/base/python-requirements-all.txt with requirements.txt in the docs dir if making any changes in them.pip install -r requirements.txt
With VS Code
-
Open Visual Studio Code.
-
File > Open Folder...
and navigate to thelexpredict-contraxsuite-services/documentation/docs
directory. -
Add or edit existing
.rst
or.md
files in thesource
directory. -
If you added a new file, add it to the
toctree
.- Open
index.rst
. It is located in the root of thesource
directory. - Scroll down to the list of
toctree
s. - Add the path to your new file. Exclude the file extension.
Example (the >> shows the added file. Do not include!):
.. toctree:: :hidden: :maxdepth: 1 :titlesonly: :caption: Using ContraxSuite guides/user/create_document_type guides/user/create_document_field >> guides/user/my_new_file
- Open
-
Open the terminal panel.
-
Build the project by typing the following command and pressing
Enter
.
make html
If the changes don't appear to have taken effect (preview them in step 7), try the following:
make clean && make html
-
You can preview your changes by opening the
build/html/index.html
file in a web browser. -
Commit changes.
In Markdown files
- Use an HTML table generator
- Enter the tabular data and add approprate formatting.
- Copy the generated HTML and paste it into the Markdown (
.md
) file.
In reStructuredText files
- Use a plain-text table generator.
- Enter the tabular data.
- Copy the generated plain-text table and past it into the reStructuredText (
.rst
) file.
Coming soon: native Markdown tables (via an extension)
Note: Andrew Parsons doesn't have a working installation of ContraxSuite at the moment and wasn't able to set this up himself.
How-To Guides
- How to document your Django project using the Sphinx tool
- Documenting your Django application with sphinx
- Include documentation from docstrings
- (StackOverflow) Can't generate autodoc using Sphinx in my Django project
In conf.py
import os
import sys
import django
sys.path.append('../../../contraxsuite_services')
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
django.setup()
TODO: make this more verbose/clearer
- Open GitHub Desktop.
- Select the files you wish to commit.
- In the commit box, title the commit "CS-4402: SUMMARY GOES HERE"
- Optionally, you can add additional information.
- Push changes.
General Structure
-
All that Sphinx sees is within the
docs
directory. -
All of our documents live within the
docs/source
directory. Think of these as the "input" for Sphinx. -
All of the final HTML files live within the
docs/build
directory. Think of these as Sphinx's "output". These files are generated by runningmake html
. Do not touch anything in thedocs/build
directory.
Structures which cannot change
- Everything that Sphinx sees must remain in the
docs
directory. - The
source
andbuild
directories must keep their names; Sphinx only knows to look there. - The
source/_static
directory is home to static assets like images (in thesource/_static/img
directory) and custom CSS files (in thesource/_static/css
directory).
Structures subject to change per team discussion
- All other files and directories within
source
are free to be moved about, renamed, created, and deleted. We should talk and plan the structure as a team. - Andrew Parsons created
introduction
,configuration
,guides
,guides/user
, andguides/developer
as a rough placeholder template. These correspond to the types of content our documentation will hold—documents oriented toward installation and configuration fit under theconfiguration
directory, whereas use-case guides fit under theguides/user
directory.
Markdown
This project uses the CommonMark Markdown flavor.
reStructuredText
- sphinx-docs
- Sphinx and RST syntax guide (0.9.3)
- rest-sphinx-memo
- docutils
- Plain text tables generator
rst vs md
Sphinx, technical
git
coming soon
To be determined
Decide on the optimal make html
command.
-j 2
number of cores used to compile
-dirhtml
Build HTML pages, but with a single directory per document. Makes for prettier URLs (no .html) if served from a webserver.