mkodcs plugin#
mkdocs の便利なpluginを以下に紹介
#
mkdocs-git-revision-date-localized-plugin
mkdocs-gen-files#
install#
Usage#
mkdocs.ymlファイルに以下を記述して、設定を有効化
スクリプトファイルを用意する
gen_pages.py
import mkdocs_gen_files
with mkdocs_gen_files.open("foo.md", "w") as f:
print("Hello, world!", file=f)
上記は簡単な例だが、もう少し複雑な例は以下の通り
ge_pages.py
import mkdocs_gen_files
for total in range(19, 100, 20):
filename = f"sample/{total}-bottles.md"
with mkdocs_gen_files.open(filename, "w") as f:
for i in reversed(range(1, total + 1)):
print(f"{i} bottles of beer on the wall, {i} bottles of beer ", file=f)
print(f"Take one down and pass it around, **{i-1}** bottles of beer on the wall\n", file=f)
mkdocs_gen_files.set_edit_path(filename, "gen_pages.py")