new Mkdocs¶
$ mkdocs new my-project
INFO - Creating project directory: my-project
INFO - Writing config file: my-project/mkdocs.yml
INFO - Writing initial docs: my-project/docs/index.md
$ cd my-project/
$ ls -la
drwxr-xr-x@ 4 yuichitamiya staff 128 5 20 14:16 .
drwx------@ 38 yuichitamiya staff 1216 5 20 14:16 ..
drwxr-xr-x@ 3 yuichitamiya staff 96 5 20 14:16 docs
-rw-r--r-- 1 yuichitamiya staff 19 5 20 14:16 mkdocs.yml
Tamiyas-MacBookPro-7:project yuichitamiya$ nano mkdocs.yml
site_name: My Docs
add
site_name: My Docs
site_description: My test site
site_author: me
docs_dir: docs
site_dir: _site
copyright: Creative Commons Attribution Non Commercial
theme:
name: mkdocs
$ mkdocs serve
INFO - Building documentation...
INFO - Cleaning site directory
[I 200520 14:34:30 server:292] Serving on http://127.0.0.1:8000
[I 200520 14:34:30 handlers:59] Start watching changes
[I 200520 14:34:30 handlers:61] Start detecting changes
theme:
name: readthedocs
css¶
$ cd docs
$ mkdir stylesheets
$ cd stylesheets/
$ touch extra.css
Add to mkdocs.yml
extra_css:
- 'stylesheets/extra.css'
Material theme¶
$ pip3 install mkdocs-material
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 PyYAML-5.3.1 Pygments-2.6.1 click-7.1.2 future-0.18.2 importlib-metadata-1.6.0 joblib-0.15.1 livereload-2.6.1 lunr-0.5.8 markdown-3.2.2 mkdocs-1.1.2 mkdocs-material-5.2.0 mkdocs-material-extensions-1.0 nltk-3.5 pymdown-extensions-7.1 regex-2020.5.14 tornado-6.0.4 tqdm-4.46.0 zipp-3.1.0
Add to mkdocs.yml
theme:
name: 'material'
custom_dir: 'custom_dir'
align images¶
Markdown
![image alt >](/image-right.jpg)
![image alt <](/image-left.jpg)
![image alt ><](/center-image.jpg)
stylesheet
img[alt$=">"] {
float: right;
}
img[alt$="<"] {
float: left;
}
img[alt$="><"] {
display: block;
max-width: 100%;
height: auto;
margin: auto;
float: none!important;
}