Welcome
This a gathering of most of my documentation written while debugging and troubleshooting.
Mostly for 1 reason
I remember this problem ... but not the solution
So it will be a mix of chapters and a chronological troubleshooting list which is meant for 1 reader (myself) but by all means be my guest when a solution fits.
Also I made cheatsheet collection that will find its way here as well, plus the google-docs, references and excerpts.
First a chapter about the tool that this site was made with :
Mkdocs
For full documentation visit mkdocs.org
tips
tips
I start with tips because I will need them building this documentation so the higher up the better.
links
Internal links just take relative paths, example :
Please see the [project license](../about/license.md) for further details.
or in the [same directory](chapter2.md)
line breaks
admonitions
watch out !
This will show a message in a warning box
Math
see visit for more info
This :
Will render as :
code
converting old documents from .rst
| steps from rst to md | |
|---|---|
Some explanation, pandoc only seems to convert code-block's to
So the last command searches and replaces that with a default code header.
The script below runs pandoc for every .rst file in the directory. After that it is manual labour :
- Auto does nothing, but it gives something to search for and change.
- So does changetitle.
- Also remove linenums if it does not make sense. Setting it to "0" works.
Actually, setting linenums higher makes it start at that line.
| rst_to_md.sh NOT actually starting at 10 | |
|---|---|
After this script edit all *.md files and search for auto and changetitle and finish the conversion. Then remove the rst files.
The last line takes care of pandoc's escaping of characters like ',",\, into \',\",\\,\. It changes a backslash followed by one character into only that character. Otherwise we would have a problem with for instance postgres commands. pandoc make '\c' into '\\c' and just removing backslash make that a plain 'c' So this version works in almost all cases.
Deploy to nduss.nl
Deployment is done with ansible.
This should do the trick IF :
- you have provided a vault password in the file .vault_password.txt
- added vault_password_file = .vault_password.txt to ansible.cfg
Otherwise you should use the password option to ansible-playbook and ansible-vault.
Top menu
Just enable these all, it causes the highest level in your document hierarch to appear as tabs in your site. instant just makes it load faster. Visit the navigation page for all the possibilities.
features:
- navigation.tabs
- navigation.tabs.sticky
- navigation.instant
- navigation.tracking
Sticky means the menu stays visible if you scroll down.
Commands
mkdocs new [dir-name]- Create a new project.mkdocs serve- Start the live-reloading docs server.mkdocs build- Build the documentation site.mkdocs -h- Print help message and exit.
Note that mkdocs server sometimes crashes with a message like
FileNotFoundError: [Errno 2] No such file or directory: '/home/kees/projects/doc/klopt/docs/data/databases/couchdb.md~'
This is because it detects a file that you were editing with vim, when you save and exit it detects changes in the vim swapfile couchdb.md~ but when it wants to process that file it is already deleted.
Disabling the swap file is probably best to avoid this. Create a local vimrc file and add .
Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
site/
index.html # etc, the generated site !
...
converting rst to md
Just a quicky, this one give almost good results ;)
Just ignore error about spellings, delete them afterwards!
Material theme
The material theme has a lot of plugins and just looks neat. The documentation is also very good : visit
For instance this page that changes colors as direct example :
Note you can always visit mkdocs to see what the default theme looks like. Actually you can choose readthedocs theme out-of-the-box as well.
mkdocs.yml
A usable mkdocs.yml for the examples in the rest of this page is :
Note: i stopped updating this so it will be different now, just look in the source dir.
dev_addr: '127.0.0.1:8010'
site_name: My Docs
theme:
name: material
palette:
scheme: default
primary: orange
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite:
- pymdownx.snippets:
- pymdownx.tasklist:
custom_checkbox: true
clickable_checkbox: true
- attr_list:
- md_in_html:
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- admonition:
- pymdownx.details:
- pymdownx.tabbed:
alternate_style: true
custom css
One problem with the material theme is it does not use full screen width when you resize the width. Here is a small fix for that.
You can customize css by adding some extra css to mkdocs like this.
And of course also provide the file :
@media only screen and (min-width: 76.25em) {
.md-main__inner {
max-width: none;
}
.md-sidebar--primary {
left: 0;
}
.md-sidebar--secondary {
right: 0;
margin-left: 0;
-webkit-transform: none;
transform: none;
}
}
This indeed does the trick, both sidebars remain the same width and the middle column is widened. The menu is now centered but this is much better use of the given space.
external links
Will render
internal links
It says .md here but the engine is smart enough to find the html equivalent.
admonitions
An annotation
with some text
code blocks
An example with title, linenumbers and highlight is
| bubble_sort.py | |
|---|---|
diagrams
Using mermaid js, see here:
Just to show it works :
``` mermaid
graph LR
A[Start] --> B{Error?};
B -->|Yes| C[Hmm...];
C --> D[Debug];
D --> B;
B ---->|No| E[Yay!];
```
graph LR
A[Start] --> B{Error?};
B -->|Yes| C[Hmm...];
C --> D[Debug];
D --> B;
B ---->|No| E[Yay!];
code in separate tabs
=== "C"
``` c
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
```
=== "C++"
``` c++
#include <iostream>
int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
```
Above code will show up like this :
box at the right side
Info
some text that will pass the spelling checker
With some more text , the box Will appear on the right side.
assets
One thing to note is where to put images etc. For instance let's take the logo image. The documentation says to put a line (almost) like this in mkdocs.yml
Ok, but we have to provide the png file. And where to put that ? It should be in docs/assets/images/klopt.png as far as i see it.
Before running mkdocs build the site directory looks like this .
So favicons was already there, and we did not put it there so it is default. Now these commands
This gives :
Showing that the default and docs/assets/images are merge into one. Just as we want and both favicon an logo can be found.
titles and sort order.
To get the ordering you want, but also the title you want, prepend the file name with a number, and use a markdown Title. For instance name the directory or file "02-vue-tasks.md", but in the md file use set another title.
Title: Vue Tasks App
Summary: Vue implementation of the tasks app.
Now the 02 will sort after 01, But the the title will be "Vue Tasks App". So the ordering follows the file names, but "Title" overrides the filename.
vue-lexer
To be able to use .vue files in mkdocs/pygments you can use
It can handle the combined html and js for vue files, but also it can be used to create svg files to further augment with annotations. An example, this code.
This can be made into an svg file with :
Then add some annotations in inkscape and add the image with