This documentation uses MkDocs - documentation using Markdown. This is an open source system that takes a folder system of markdown files with associated files (eg images) and renders them into HTML with nice features like site navigation and search, and on page navigation. It is similar to other services like Jekyll or OctoPress, but it is focused on documentation, not blogging.
We can fully change the theme used and its features using a basic templating language and normal CSS. If needed you can insert HTML into the Markdown files and it will get passed through as HTML.
- write and edit in markdown
- make sure new pages are accessible using the main navigation (in the mkdocs.yml)
- check that there are no broken images or links
- save, commit, and push your changes to Github - this gets the source code of our documentation in place
- deploy from a local machine using a simple command from the command line to build, commit, push, and deploy the rendered files to Github
- Github hosts these deployed files as a static site
- Quick fixes should be done on master - eg typos
- New pages or larger changes should be done in a branch off master (eg. reporting-pages)
- There is a special branch called "gh-pages" that you should NEVER touch. It is the deployment branch and is handled automatically by MkDocs.
-
Refer to MkDocs to install Python, pip, then MkDocs
-
We use the Material theme for mkdocs. This has two versions - a public and an Insiders version.
- Public: run
pip install mkdocs-material
it should also install MKdocs. - Insiders run
pip install git+https://${token}@github.com/squidfunk/mkdocs-material-insiders.git
- replace {token} with your relevant token
- Public: run
-
Run
pip install Pygments
from the command line - this library is used to provide nicer syntax highlighting for code -
Run
pip install pymdown-extensions
to allow extra markdown formatting options to the rendering -
Run
npm install broken-link-checker -g
(need node and npm for this) - used for checking for broken links before deployment. For more info see here -
Run
pip install mkdocs-redirects
to enable proper redirect handling of old pages or links that we no longer need -
Run
pip install mike
if we are using versions to provide support for multiple document versions -
Clone this repo to your local machine
- How to create files and style them
- Markdown is a straightforward way to write human readable text that renders to display HTML headings, bold, italics, links, images, numbered lists, bulleted lists, tables, line breaks, and code blocks.
- To make a paragraph make sure to leave an empty line between paragraphs (ie press return twice)
- You don't need to leave an empty line between list items
- You can have a list that has differently indented levels. Make sure each new indent uses 4 spaces
- Using MkDocs you can also make links to places in other files in the documentation which is really handy
-
Running a local test server: from the current branch, run
mkdocs serve
. The web server should be available at localhost:8000 -
Edit and commit your documentation changes: files can be edited and committed straight on Github, and created, deleted, or edited from the desktop. Work in the relevant branch (master to make the changes live) and commit code as normal using Git.
-
CHECK FOR ERRORS:
- run
mkdocs build
- this will show pages not linked in the navigation (likely fine) and images broken links that you can then repair - run
mkdocs serve
then in a new terminal window runblc http://localhost:8000 -ro -e
. This checks for internal links only - run in dedicated command prompt / terminal (do not run from VS Code as it truncates the console output) - once this has finished (will take a few minutes) search in the output for "─BROKEN─". This will give you the bad link and you can see above the page the link is on (the line above starting "Getting links from: http://localhost:8000...").
- you can separately run
blc http://localhost:8000 -ro -i
to check for external broken links but this will throw lots of errors on things like twitter on every page
- run
-
Deploy to to GitHub Pages: from the local machine when on the master branch, run
mkdocs gh-deploy
and that's it! Your changes should be live after the command finishes!
Can run mkdocs build --clean
. After some time, files may be removed from the documentation but they will still reside in the site directory. Run this command to remove those stale files.
From the tools directory, run the command python .\unusedimgs.py
. This will generate a list of commands you can paste into the console to delete the file. PLEASE READ LIMITATIONS BEFORE YOU PROCEED AND DELETE IMAGES
- If an image name has a parenthesis in it (like
Importing_from_Microsoft_Excel_(Office365)_24.png
), the script will print it out no matter what. Please review them before you delete in case they are actually used. - If the image reference is across multiple lines (like the example below), the image will be printed out. Please move the reference to one line and run the command again and it should disappear.
...
![Git stores data as snapshots of the project over time.](img/Using_Git_47.png)
...
- To combine paragraphs split across multiple lines:
([A-Za-z",\*<>\. 0-9&\(\)])\n([A-Za-z",\*<>\. 0-9&\(\)])
=>$1 $2
- To get rid of extra line breaks:
\n\n\n
=>\n\n
and run until it can't be run anymore - To add spacing before headings:
\n#
=>\n\n#
- Install MiTeX
- Install pyyaml with
pip install pyyaml
- Review the
convert
array increatepdf.py
, which will automatically convert toplevel items in thenav
inmkdocs.yml
to a PDF. Each toplevel entry will get its own PDF. - Review
Admin Guide.yml
andUser Manual.yml
in the tools directory. These contain the formatting for the header and footer\fancyhead[LO,LE]{SpiraPlan Administration Guide}
will putSpiraPlan Administration Guide
in the top (fancyhead
) left ([L*,L*]
) of odd and even pages ([*O,*E]
)\fancyfooter
works the same
- In the tools directory, run the command
python .\createpdf.py
Possible Issues: If a line starts with a file/folder URI (ex. C:\WINDOWS), the script will error out. Just find the ofending line in the markdown and format it in some way (wrapping it with grave marks (`) to make it format as code works well.)
- Install mkdocs with
pip install mkdocs
, if you haven't already. Note that you need pip and Python for this to work. - Install Pandoc
- In the tools directory, paste the .docx files you would like to convert. Note that only .docx files will be converted - if you have a .doc or another format, either save it as a docx or convert it manually
- In a shell,
cd
to tools and runpython .\spiraconvert.py options
where options is either 'auto' (python .\spiraconvert.py auto
) or the names of the files you would like to convert without the file extension (python .\spiraconvert.py "SpiraTestPlanTeam IDE Integration Guide" "SpiraTestPlanTeam External Bug Tracking Integration Guide" "SpiraTest-Team Automated Testing Integration Guide"
) - The script will run, copying files into the
./temp
folder in the root directory as it goes. These markdown files and the images should be pasted into the./docs
directory in the appropriate folders. - Review the files for weirdness (more information below)
- Put all the new files in mkdocs.yml where you would like. The
nav
property will generate the top navbar in the structure you define. Runmkdocs serve
to test it out, which can be viewed at http://127.0.0.1:8000/
- Table formatting is generally a huge pain and needs to be done manually
- Code usually isn't formatted and generally has excessive escape characters (I just pasted the code directly from word as it was easier)
- The script will spit out an uneccesary
Introduction
orLegal
file if it was present or put a legal notice in the.md
file who's corresponding section in the word file was at the bottom of the word file. - Unnecessary escape characters: Just do a find and replace in your editor of choice in the
docs\
directory with the criteria below:- \< to <
- \> to > IFF THE OCCURANCE IS IN A CODE BLOCK, OTHERWISE NECESSARY
- \" to "
- \' to '
- \@ to @
- ^®^ to ®
- ^1^ to 1
- $ to $