- 跟 Hexo 不同,MkDocs 只能寫 pages,跟 Hexo 以 blog posts 為主 (pages 為輔) 的應用不同。
參考資料:
- Automate publishing to PyPI with pbr and Travis - Dougal Matthews (2016-09-01) 提到
retrace
用 MkDocs 來產生文件 -- 就是 retrace 的官網,採用 Materials theme (Google 風)。 - MkDocs MkDocs is a fast, simple and downright gorgeous static site generator that's geared towards building PROJECT DOCUMENTATION. 專用於 project 網站,再適合不過 GitHub Pages 之類的應用。
- Dougal Matthews - MkDocs: Documenting projects with Markdown - YouTube 00:25 作者唸做 "m-k-ducks"
- python-fire/mkdocs.yml at master · google/python-fire => Using a CLI - Python Fire
- pinax/mkdocs.yml at master · pinax/pinax => Pinax Moves from Sphinx to MkDocs | The Pinax Project Blog (2015-10-19) 從 Sphinx 遷移到 MkDocs,因為寫了許多年的 reStructuredText,還是很常需要查詢語法;Pinax 在 Django 上發展出許多 starter projects。
- markdown/mkdocs.yml at master · Python-Markdown/markdown
- Swap out Sphinx for mkdocs · Issue #7 · drivendata/cookiecutter-data-science #ril
- nodemcu-firmware/mkdocs.yml at master · nodemcu/nodemcu-firmware
- Search · filename:mkdocs.yml 更多 ...
$ mkdocs new helloworld
INFO - Creating project directory: helloworld
INFO - Writing config file: helloworld/mkdocs.yml
INFO - Writing initial docs: helloworld/docs/index.md
$ cd helloworld
$ mkdocs serve
INFO - Building documentation...
INFO - Cleaning site directory
[I 180831 04:52:38 server:292] Serving on http://127.0.0.1:8000
[I 180831 04:52:38 handlers:59] Start watching changes
[I 180831 04:52:38 handlers:61] Start detecting changes
$ open http://localhost:8000
$ vi mkdocs.yml
site_name: Hello, World!
- Getting Started - MkDocs
mkdocs new my-project
會產生my-project/
,底下有mkdocs.yml
及docs/index.md
-- 其中mkdocs.yml
是 configuration file,而docs/
則是放置 documentation source files 的地方。- 內建 dev-server,在
mkdocs.yml
的目錄執行mkdocs serve
即可,就可以從 http://127.0.0.1:8000 看到內容 - 從
Start watching/detecting changes
的訊息看來,預設就有 auto-reloading 的功能 -- 當 configuration file (mkdocs.yml
)、documentation directory (docs/
) 或 theme directory 有異動時就會自動 rebuild,而且 browser 也會 auto-reload。 - 透過
pages:
可以列舉 navigation header 的項目,例如- Home: index.md
、Aboud: about.md
;雖然還是有效,但這在 configuration 的手冊裡已經找不到,原來在 Version 1.0 (2018-08-03) 被nav:
取代。
- File Layout - Writing Your Docs - MkDocs
- Documentation source (Markdown files) 必須放在 documentation directory (
docs_dir
) 下,預設是docs/
(跟mkdocs.yml
同一層);實驗發現,試圖設定docs_dir: .
會出錯,也就是mkdocs.yml
跟.md
不能在同一個目錄。 - Markdown source files 的副檔名是
.md
(或.markdown
、.mdown
、.mkdn
、.mkd
),只要是在docs_dir
下的 Markdown source file 都會被 render,不管設定為何;這間接說明了,文件不一定要列入nav
configuration。通常 project homepage 的主檔名是index
(也可以是README
)。 - The file layout you use determines the URLs that are used for the generated pages. You can also include your Markdown files in NESTED DIRECTORIES if that better suits your documentation layout.
docs/license.md
對應 URL/license/
(背後是site/license/index.html
),而user-guide/getting-started.md
則對應 URL/user-guide/getting-started/
(背後是site/user-guide/getting-started/index.html
);這一點很適合拿來做筆記,因為單篇xxx.md
未來都可以往下展開細節。
- Documentation source (Markdown files) 必須放在 documentation directory (
- Index pages - Writing Your Docs - MkDocs
- When a directory is requested, by default, most web servers will return an index file (usually named
index.html
) contained within that directory if one exists. 因些上面的 homepage 才會取名index.md
-- 產生index.html
;不過有些 repository hosting 會顯示README
file,所以 MkDocs 也接受README.md
做為 homepage -- 也會產生index.html
。 - 如果同時存在
index.md
與README.md
,則 MkDocs 會優先採用index.md
。
- When a directory is requested, by default, most web servers will return an index file (usually named
原來 navigation 打破階層後,page 之間還是有順序的,使用者可以依序看,也可以跳著看,但都在安排好的脈絡上,這一點還滿特別的。以內建的兩個 theme 而言,套上 mkdocs
看起像個網站,但套上 readthedocs
後,看起來又像本書了。
參考資料:
- Configure Pages and Navigation - Writing Your Docs - MkDocs
nav
configuration 定義了哪些 page 會出現在 global site navigation menu 以及 menu 本身的結構;如果沒有設定nav
,預設會找出docs_dir
下所有的 Markdown files,並按照檔名的字母順序排列 (當然 index file 會被排在第一個位置),可想而知,這通常都不會是你想要的。nav
configuration 有兩種寫法 --- 'index.md'
或- Home: 'index.md'
(路徑總是相對於docs_dir
),後者會採用Home
做為 title,前者則會從檔案內容取得 title;不過若是後者的表示法自訂 title 後,檔案內容的 title 也會被覆寫,聽起來不太妙 XD- Navigation sub-sections,可以將相關的 page 列在一個 section title 下,例如
- User Guide:
,但本身不能指向 page -- sections are only containers for child pages and sub-sections。雖然階層數沒有限制,但別讓使用者迷失了。 - Any pages not listed in your navigation configuration will still be rendered and included with the built site, however, they will not be linked from the global navigation and will not be included in the PREVIOUS AND NEXT LINKS. 這一點比 GitBook 好多了。
- 實驗發現沒列在
nav:
裡的.md
也會被解析,在 dev-server 的 log 會看到類INFO - The following pages exist in the docs directory, but are not included in the "nav" configuration: ...
的訊息,在 Search 裡也找得到。
-
markdown_extensions - Configuration - MkDocs #ril
-
MkDocs 是用 Python-Markdown 將 Markdown 轉成 HTML,而 Python-Markdown 支援許多 extension 用來自訂 "how pages are formatted",
markdown_extensions
就是用來啟用額外的 extension。MkDocs 預設會啟用meta
、toc
、tables
、fenced_code
;根據 source code 看來,預設並沒有meta
。 -
從範例
- toc: permalink: True
看來,markdown_extension
不只可以用來啟用其他 extension,也可以用來設定預設會被啟用的 extension。markdown_extensions: - smarty - toc: permalink: True - sane_lists
-
-
Incorrect rendering of nested lists · Issue #545 · mkdocs/mkdocs #ril
- d0uga: (member) 因為上遊 Python-Markdown 要求 2nd level list 要內縮 4 格,不認為這是個 bug。
- waylan: 建議 rufuspollock 應該把時間花在 making well-formed Markdown documents ...
- rufuspollock: 手邊有很多文件都是內縮 2 格 (很多都是別人提供的),
markdown.pl
也沒這麼做,而且 CommonMark 看似也允許 2 個空格。
-
Nested lists require 4 spaces of indent · Issue #3 · Python-Markdown/markdown
- 結論是不修,但後來 radude 發表了一個 Python-Markdown extension;如何讓 MkDocs 套用? => 在
markdown_extension
加上mdx_truly_sane_lists
即可。
- 結論是不修,但後來 radude 發表了一個 Python-Markdown extension;如何讓 MkDocs 套用? => 在
-
Indented code block not transformed · Issue #282 · mkdocs/mkdocs #ril
- jsaintro: MkDocs 的 backticks 只能用在 non-indented code block,但 1st level list 可以搭配內縮 8 格,2st level list 內縮 12 格,依此類推。
- Meta data 裡可以定義
title:
,否則就會抓取 heading 1。
- Customizing a Theme - Styling Your Docs - MkDocs #ril
- MkDocs includes a couple built-in themes as well as various third party themes, all of which can easily be customized with extra CSS or JavaScript or overridden from the theme's
custom_dir
. 可以在 theme 上面再疊加一層自訂;不過還有比custom_dir
更簡單的做法 --extra_css
/extra_docs
(搭配docs_dir
使用)。 - If you would like to make a few tweaks to an existing theme, there is no need to create your own theme from scratch. For minor tweaks which only require some CSS and/or JavaScript, you can use the
docs_dir
. However, for more complex customizations, including overriding templates, you will need to use the themecustom_dir
setting. 簡單的透過docs_dir
,複雜的再用custom_dir
。
- MkDocs includes a couple built-in themes as well as various third party themes, all of which can easily be customized with extra CSS or JavaScript or overridden from the theme's
- Build directories - Configuration - MkDocs #ril
- MkDocs Recipes · mkdocs/mkdocs Wiki 一些 recipes 跟 custom CSS 有關 #ril
- 文件內容的 HTML 是由 Python-Markdown (及啟用的 extensions) 產生,所以 theme 只是針對 Markdown 會產生的 HTML 先設計好 stylesheets 而已,並無法改變它的結構??
推薦的 theme 有:
參考資料:
- mkdocs/build.py at 1.0.4 · mkdocs/mkdocs
_populate_page(file.page, config, files, dirty)
內部會呼叫 Python Markdown 產生本文的 HTML (page.content
) 及 TOC (page.toc
),之後_build_page(file.page, config, files, nav, env, dirty)
會寫出檔案。 - MkDocs Great themes available: 除了內建的
mkdocs
與readthedocs
,還有許多 3rd-party themes,當然也可以自己做。 - Theming our documentation - MkDocs 在
mkdocs.yml
加上theme: readthedocs
,神奇的事發生了!! 不要重啟 server,整個變成 Read the Docs 風 ~ - Styling Your Docs - MkDocs #ril
- Custom Themes - MkDocs #ril
- MkDocs Themes · mkdocs/mkdocs Wiki #ril
- Material for MkDocs 很專業的感覺!! #ril
- MkDocs Bootswatch Themes 文件的 TOC 在左側 (只到 L2?),就沒有所有文件的導覽;適用數量很多的筆記。
- Lucas Ramage / mkdocs-bootstrap386 · GitLab 模擬 console 的感覺,但 TOC 只到 L2。
- Search results · PyPI ... 更多
- Internal links - Writing Your Docs - MkDocs 提到
toc
extension #ril - Anchor Linking with Heading Sections · Issue #744 · mkdocs/mkdocs 搭配
attr_list
extension 可以自訂 ID;這對中文 header 尤其重要,例如## 新手上路 {: #getting-started }
- waylan: (member) if you have the
permalink
option of thetoc
extension enabled, then every header will be assigned anid
. For example, the following header:# A Header
Will produce the following HTML:<h1 id="a-header">A Header</h1>
. Note that theid
is assigned the SLUG:a-header
. - waylan: if you enable the
attr-list
extension, that will allow you to define custom ids for your headers. Those ids will then be used rather than the auto-generated ones. Attribute Lists — Python-Markdown 3.0.1 documentation 提到### A hash style header ### {: #hash }
會產生<h3 id="hash">A hash style header</h3>
,因為 A word which starts with a hash (#
) will set the id of an element.
- waylan: (member) if you have the
- 預設就會有 TOC,如何在特定頁面關閉??
- Meta-Data - Writing Your Docs - MkDocs #ril
- YAML Style Meta-Data - Writing Your Docs - MkDocs 範例提到
author:
(list) 與date:
,但試過theme
、readthedocs
及material
都不會顯示這兩項資訊??
- tag and category support? · Issue #1411 · mkdocs/mkdocs 靠 meta data,但好像沒有 plugin? #ril
- Tagging support · Issue #759 · mkdocs/mkdocs 未來可以透過 plugin 提供。
- Preview your site as you work - MkDocs 內建 dev-server 可以預覽文件,甚至存檔時 browser 會自動 reload!
- Getting Started - MkDocs
mkdocs.yml
是 configuration file,示範site_name
可以改變網站的名稱。 - Project Information - Configuration - MkDocs #ril
- 全部的組態都集中在 project directory 的
mkdocs.yml
,裡面除了site_name
之外,其他都是非必要的。 site_name
- 做為 main titlesite_url
- 設定 canonical URL。This will add a LINK TAG with the canonical URL to the generated HTML header. 例如<link rel="canonical" href="https://imsardine.github.io/dev-notes/markdown/">
。實驗確認可以帶 path,例如https://imsardine.github.io/dev-notes
,產生的文件其間都用相對路徑串聯,所以不會有問題。repo_url
- 提供 repository (GitHub、Bitbucket、GitLab 等) 的連結,例如https://github.com/example/repository/
;試過 Material theme,會根據 URL 顯示 GitHub、GitLab 不同的圖示。
- 全部的組態都集中在 project directory 的
- Documentation Layout - Configuration - MkDocs #ril
- Build Directories - Configuration - MkDocs #ril
- Preview Controls - Configuration - MkDocs #ril
- Formatting Options - Configuration - MkDocs #ril
- Other Commands and Options - MkDocs
mkdocs --help
或mkdocs <command> --help
。
- Changing the Favicon Icon - MkDocs Markdown 預設採用同 MkDocs 官網的 favicon (黑色的筆記本),將自訂的圖放在
docs/img/favicon.ico
,MkDocs 就會自動偵測到並採用它。
- Building the site - MkDocs #ril
mkdocs build
會在site/
輸出 HTML;注意docs/index.md
與docs/about.md
會分別被輸出成site/index.html
與site/about/index.html
,其他 media 也被複製進site/
。- 還有
sitemap.xml
、mkdocs/search_index.json
? MkDocs 1.0.3 實際的輸出是sitemap.xml
(外加sitemap.xml.gz
)、search/search_index.json
,另外還有404.html
- 加
--clean
才會清理site/
多出來的東西? 不過為什麼不加--clean
前,mkdocs build
就會看到INFO - Cleaning site directory
的 log??
- Version 1.0 (2018-08-03) - Release Notes - MkDocs Support for hidden pages. All Markdown pages are now included in the build regardless of whether they are included in the navigation configuration (#699).
- Building hidden pages · Issue #699 · mkdocs/mkdocs (2015-07-27) #ril
- Build pages without adding them to sidebar? · Issue #230 · JuliaDocs/Documenter.jl (2016-08-23)
- tlnagy: 有沒有可能限制 content tree 的深度,會讓 sidebar 變得很長,但有些 page 又不那麼重要 (要列在 sidebar 裡)。
- MichaelHatherly: (member) 或許 navmenu 可以預設合起來? 又或者像 GitBook 一樣把 navmenu 安排在分開的 frame 裡。
- mortenpi: (member) We could introduce the system that all .md files get built, even if they're not in the navmenu 過去有個決定會略過不在
pages
裡的檔案,但這做法可以討論。 - tlnagy: 實務上會安排 "link to all the pages" 的頁面,猜想大部份的人不會在意多點一下,而且這樣會讓 navbar 不那麼雜亂。
- MichaelHatherly: (member) Yes, that approach looks good — just keep the "MAIN" TOPICS easily reachable from the navmenu and have the others reachable through IN-PAGE CONTENTS seems like a good compromise to me. 開發團隊接受了 tlnagy 的提議,而這正是 GitBook 的缺點。
- mortenpi: (member) what about pages that are completely disconnected (i.e. no links to them) -- should we try to find them and warn the user?
- 後續的討論都沒有看到 MkDocs 有上述的修改,這才發現這個 issue 屬於 JUliaDocs,看似受到 MkDocs 的影響很深,中間一度提到 "decided to be consistent with MkDocs"
- Project Information - Configuration - MkDocs 發現
site_url
也用在產生build/sitemap.xml
,否則裡面的<loc>
的內容會是None
(1.0.4);顯然 "As a minimum this configuration file must contain the site_name setting." 這句話是有問題的,因為 sitemap 預設就會產生。 - Release Notes - MkDocs
- Version 1.0 (2018-08-03) - Compress sitemap.xml (#1130).
- Version 0.17.4 (2018-06-08) - Bugfix: Add multi-level nesting support to sitemap.xml (#1482).
- Version 0.13.0 (2015-05-26) - Generate sitemaps for documentation builds. (#436)
- MkDocs 開始有 "Support for hidden pages",但 sitemap 卻沒有考慮到 hidden pages (1.0.4) ??
- mkdocs/build.py at master · mkdocs/mkdocs
if template_name == 'sitemap.xml':
看來是def _build_theme_template(template_name, env, files, config, nav):
的files
一開始就少了 hidden files? - mkdocs/sitemap.xml at 1.0.4 · mkdocs/mkdocs 原來
templates/sitemap.xml
就只會遶nav
而非files
,可能是為了要與 navigation menu 階層對應的關係?
- mkdocs/build.py at master · mkdocs/mkdocs
- Sitemap 裡的
<lastmod>
是如何決定的 => 1.0.4 採用SOURCE_DATE_EPOCH
或系統時間-
mkdocs/sitemap.xml at 1.0.4 · mkdocs/mkdocs
{% if item.update_date %}<lastmod>{{item.update_date}}</lastmod>{% endif %}
-
mkdocs/pages.py at 1.0.4 · mkdocs/mkdocs 由
SOURCE_DATE_EPOCH
決定,或是取當下系統時間;也就是重新產生就更新,或許可以把最後一個 commit 的時間寫進SOURCE_DATE_EPOCH
,就能達成 reproducible build 的效果?# Support SOURCE_DATE_EPOCH environment variable for "reproducible" builds. # See https://reproducible-builds.org/specs/source-date-epoch/ if 'SOURCE_DATE_EPOCH' in os.environ: self.update_date = datetime.datetime.utcfromtimestamp( int(os.environ['SOURCE_DATE_EPOCH']) ).strftime("%Y-%m-%d") else: self.update_date = datetime.datetime.now().strftime("%Y-%m-%d")
-
- MkDocs 把
site/
的內容上傳,這裡提到 GitHub project pages、Amazon S3。
-
拿
mkdocs new .
產生的docs/index.md
來測試,先改寫裡面只有 code block,再觀察搭配不同設定所產生的 HTML。# Welcome to MkDocs from __future__ import print_function print("Hello, World!") # Python 2-3 compatible code
在沒有自訂其他 extension 的情況下,產生的 HTML source 為:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> <pre><code>from __future__ import print_function print("Hello, World!") # Python 2-3 compatible code </code></pre>
DOM 會被加工成:(針對
<code>
)<pre><code class="hljs coffeescript"><span class="hljs-keyword">from</span> __future__ <span class="hljs-keyword">import</span> print_function <span class="hljs-built_in">print</span>(<span class="hljs-string">"Hello, World!"</span>) <span class="hljs-comment"># Python 2-3 compatible code</span> </code></pre>
由
class="hljs coffeescript"
看來,highlight.js 判斷失準。改寫成 fenced code block 並提示 language:```python from __future__ import print_function print("Hello, World!") # Python 2-3 compatible code ```
HTML source 帶有
python
的提示:<pre><code class="python">from __future__ import print_function print("Hello, World!") # Python 2-3 compatible code </code></pre>
DOM 會被加工成:
<pre><code class="python hljs"><span class="hljs-keyword">from</span> __future__ <span class="hljs-keyword">import</span> print_function print(<span class="hljs-string">"Hello, World!"</span>) <span class="hljs-comment"># Python 2-3 compatible code</span> </code></pre>
但 indented code block 如何提示 langage??
-
重複上面的實驗 (回到 indented code block),試試加入
codehilite
markdown extension 後,會起什麼變化? HTML source 變成:<pre class="codehilite"><code>from __future__ import print_function print("Hello, World!") # Python 2-3 compatible code</code></pre>
從
<pre class="codehilite">
看到codehilite
extension 開始作用。由於這時候 highlight.js 的程式都還在,所以 DOM 還是會被加工:<pre class="codehilite"><code class="hljs coffeescript"><span class="hljs-keyword">from</span> __future__ <span class="hljs-keyword">import</span> print_function <span class="hljs-built_in">print</span>(<span class="hljs-string">"Hello, World!"</span>) <span class="hljs-comment"># Python 2-3 compatible code</span></code></pre>
事實上,因為還沒裝 Pygments 套件的關係,所以
codehilite
extension 等同沒有效果 (use_pygments: false
)。安裝 Pygments 套件後,HTML source 變成:<div class="codehilite"><pre><span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span> <span class="k">print</span><span class="p">(</span><span class="s2">"Hello, World!"</span><span class="p">)</span> <span class="c1"># Python 2-3 compatible code</span> </pre></div>
很明顯地
<pre class="codehilite">
變成<div class="codehilite">
,而且<pre>
底下沒有<code>
了,也之所以雖然 highlight.js 的程式都還在,但 DOM 不會被加工,但為何class="kn"
、class="nn"
等都沒有效果?但因為沒有 Pygments CSS 的關係,不會有 highlighting 的效果。按照 CodeHilite — Python-Markdown 3.0.1 documentation 的說法:
You will need to define the appropriate CSS classes with appropriate rules. The CSS rules either need to be defined in or linked from the header of your HTML templates. Pygments can generate CSS rules for you. Just run the following command from the command line:
pygmentize -S default -f html -a .codehilite > styles.css
也就是 Pygments 的 CSS 要自己安排:
pygmentize -S default -f html -a .codehilite > docs/pygments.css
然後在
mkdocs.yml
增加extra_css: ["pygments.css"]
,就可以看到 highlighting 的效果:<link href="pygments.css" rel="stylesheet"> <div class="codehilite"><pre><span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span> <span class="k">print</span><span class="p">(</span><span class="s2">"Hello, World!"</span><span class="p">)</span> <span class="c1"># Python 2-3 compatible code</span> </pre></div>
-
Fenced code blocks - Writing Your Docs - MkDocs 提到 syntax highlighter #ril
-
CodeHilite - Material for MkDocs Syntax highlighting 是 theme 的功能? #ril
由於 MathJax 是在前端做轉換,所以只要在 mkdocs.yml
加上:
extra_javascript:
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML
就可以讓 MathJax 作用在產生的頁面上,而 Markdown 原始文件只要注意 MathJax 的表示法不被 MkDocs 解析,可以正確地傳到前端即可。例如:
`x = (-b +- sqrt(b^2-4ac))/(2a)`
要寫成:
\`x = (-b +- sqrt(b^2-4ac))/(2a)\`
這樣 backtick 才能被送到前端:
`x = (-b +- sqrt(b^2-4ac))/(2a)`
參考資料:
-
python - MkDocs and MathJax - Stack Overflow
-
Waylan: This is actually easier than I expected. First I installed the Python-Markdown-Math Extension:
pip install https://github.com/mitya57/python-markdown-math/archive/master.zip
Next I edited the
test_math/docs/index.md
file to be as follows (sample borrowed from the MathJax documentation):# MathJax Test Page When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
Finally, I edited the
test_math/config.yaml
file to be as follows:site_name: Test Math extra_javascript: - https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML markdown_extensions: - mdx_math
即便用了 extension,還是得引用 MathJax 的 JS library,那 extension 的作用是什麼 ??
-
-
Arithmatex - PyMdown Extensions Documentation #ril
-
Arithmatex is an extension that PRESERVES LaTeX math equations during the Markdown conversion process so that they can be used with libraries like MathJax. If you prefer to use something other than MathJax, Arithmatex can output a more generic format suitable for other libraries like KaTeX.
-
Arithmatex searches for the patterns
$...$
and\(...\)
for INLINE MATH, and$$...$$
,\[...\]
, and\begin{}...\end{}
for BLOCK MATH. By default, all formats are enabled, but each format can individually be disabled if desired.難怪之前
[... \( ... \)](http://....)
這類連結在 client 端會被誤認為是 Mathjax 的 equation markup,因為pymdownx.arithmatex
這個 extension 讓 Markdown conversion 的過程中保留了\(...\)
的部份,而這正是 in-line mathematics 的寫法。
-
- Plugins - MkDocs #ril
- Plugin API. · Issue #206 · mkdocs/mkdocs #ril
- MkDocs Plugins · mkdocs/mkdocs Wiki 條列外部開發的 plugin #ril
- MkDocs 內建
readthedocs
theme,效果跟 Read the Docs 上的文件很像。 - Read the Docs - Deploying Your Docs - MkDocs #ril
- 最糟是轉向 Sphinx 產生的文件,若能將 Sphinx 產生的文件整進來也是個方式 ...
- 或許 MkDocs 內建
readthedocs
theme 的關係,讓我們混淆了 MkDocs 的定位;目前看來 Sphinx 還是寫 Read the Docs 這類文件的最佳方案,而 MkDocs 則較適合用在建立 project site?
參考資料:
-
How to build API reference docs · Issue #641 · mkdocs/mkdocs
- twiecki: Along with documentation, sphinx can auto-generate references by walking through the files and looking at the doc-strings. Is this possible or are there any plans to add this? 聽起來 Sphinx 是 MkDocs 的父集合,只是它不支援 Markdown
- d0ugal (Member): This isn't currently possible and we have no plans to add it to MkDocs itself. I would like to see this happen via the extension API when we add one. See #206. 但隨後補上 FWIW, API docs (and a general plugin API) is something that I really want in some cases. So it is bubbling up in priority for me but I have a few critical things I need to take care of first. So I have no idea when I would have time to take it on. ... 開發團隊慢慢理解到這樣的需求。
- waylan (Member) 引用了 How I Judge the Quality of Documentation in 30 Seconds — Eric Holscher - Surfing in Kansas 的說法 -- If your documentation is generated from source code, I am immediately skeptical. You should use words to communicate with your users, and those words shouldn’t live in your source code. If you included all of the things needed to document a project in source, your code would be unreadable. So please, use a tool that allows you to write prose documentation outside of your source code. Your users will thank you. ... 是有些道理,但 API 文件不同啊?
- d0ugal: Yeah, I almost totally agree. They are not a replacement to well written docs. So if all your docs are generated from code, then I think you are doing it wrong :) However, I do like them as an additional resource to prose documentation. Personally, for example, I find them particularly useful when I know a project well but I just want to look up something I've not used in a while.
- kernc: User's manual is one thing, and API reference (docstrings) is another. A minimally usable documentation tool should be able to produce a HTML of the latter. 確實是如此
- d0ugal: MkDocs has proven that automatically creating an API reference isn't required to be minimally usable given that we have many users. 認為這不是 MkDocs 最低限度要支援的功能,最後還是導向 plugin API #206 的討論。
-
generate or link to API docs · Issue #20 · mkdocs/mkdocs
- tomchristie (Contributor): Autogenerated docs isn't something I'm particular interested in pulling into mkdocs. The best documentation sites that I've seen DON'T TEND TO INCLUDE AUTOGENERATED DOCS. 不過 "I'm planning for you to be able to add regular HTML pages as well as MD pages." 的選項似乎出現了一線希望 ... tomchristie 隨後將這個 issue 關閉,轉向 #28 討論。
- rossant: 自己寫了個工具,可以根據 docstrings 產生
api.md
,然後就可以交給 MkDocs 使用。 - d0ugal (Member): 如果在產生 Markdown 為什麼不直接用 Markdown 寫文件? ... 沒進入狀況 XD 隨後 AbdealiJK 與 isms 引用其他專案想用 MkDocs 取代 Sphinx 的 issue。
- raghakot: 也寫了個 https://github.com/raghakot/markdown-apidocs。
-
Plugin API. · Issue #206 · mkdocs/mkdocs #ril
- erichulser: One of the requirements I have for documentation is auto-module/class docs as a means to augment the prose style. 看起來 prose 指的是非 docstrings 那種硬梆梆的寫法 ... . I would propose simply adding a plugin architecture to mkdocs (similar to django/pyramid) that would allow a developer to run additional addons so as to not pollute the core of the project. 原來 plugin 的想法是從這裡開始的。
- d0ugal: We absolutely don't want to include auto-generated docs for MkDocs. Doing so would be a promise to support a Python API.
- erichulser: 做了個 erichulser/mkdocs_autodoc extension
-
NiklasRosenstein/pydoc-markdown: Create Python API documentation in Markdown format.
-
Actions - Pinax Stripe 怎麼把 API reference 拼進 MkDocs 的?
- History for docs/reference/actions.md - pinax/pinax-stripe 看起來不是從 source code 自動產生的?
- pinax-stripe/charges.py at master · pinax/pinax-stripe 不過
docs/reference/*.md
的內容與 source code 裡的 docstrings 是一致的。 - add_event: get stripe_account from message · pinax/pinax-stripe@274abcf 從
reference/actions.md
反推 history,每個 commit 都會跟 source code 裡的 docstrings 一起修改,感覺有用什麼工具? - Sync subscription data immediately · pinax/pinax-stripe@86bed63 從這個 commit 看來是手動同步的;在 docstrings 寫 "Returns: the data representing the subscription object that was created",但到
reference/actions.md
就改成 "Returns: thepinax.stripe.models.Subscription
object that was created" 了。
- Installation - MkDocs 可以用 OS package manager 裝,但如果版本不夠新,還是建議用 pip 安裝
mkdocs
套件,就會有mkdocs
指令可用。
- squidfunk/mkdocs-material - Docker Hub #ril
- Search - Docker Hub 感覺自己可以弄個預裝很多 theme 及 Python-Markdown extenion 者,調整組態就能套用 ??
- Running mkdocs with Docker – Edson Alcala – Medium (2018-03-09) 重點是
mkdocs.yml
裡要加dev_addr: 0.0.0.0:8080
才能搭配docker run --publish 8080:8080
使用。
社群:
文件:
相關:
- Python-Markdown - MkDocs 背後用 Python-Markdown 將 Markdown 轉換成 HTML
手冊: