MKdoc是一个使用python进行生成静态html的项目,非常实用用来做静态的wiki或者个人文档。
Welcome to MkDocs
For full documentation visit mkdocs.org.
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.
Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
about mkdocs
MkDocs 是一个用 Python 开发的静态站点生成器工具,它可以非常简单快速的创建项目文档。MkDocs 的文档源码使用 Markdown 编写,配置文件使用 YAML 编写,可以一键编译成静态站点。
pip install mkdocs 后会一同安装如下程序:
click 8.0.4
ghp-import 2.1.0
importlib-metadata 4.8.3
Jinja2 3.0.3
Markdown 3.3.7
MarkupSafe 2.0.1
mergedeep 1.3.4
mkdocs 1.3.1
packaging 21.3
pyparsing 3.0.9
python-dateutil 2.8.2
PyYAML 6.0
pyyaml_env_tag 0.1
six 1.16.0
typing_extensions 4.1.1
watchdog 2.1.9
zipp 3.6.0
创建并使用对应的python虚拟环境
pip install mkdocs
pip install mkdocs-simple-blog
GitHub Pages
If you host the source code for a project on GitHub, you can easily use GitHub Pages to host the documentation for your project. There are two basic types of GitHub Pages sites: Project Pages sites, and User and Organization Pages sites. They are nearly identical but have some important differences, which require a different work flow when deploying.
Project Pages
Project Pages sites are simpler as the site files get deployed to a branch within the project repository (gh-pages by default). After you checkout the primary working branch (usually master) of the git repository where you maintain the source documentation for your project, run the following command:
mkdocs gh-deploy
That's it! Behind the scenes, MkDocs will build your docs and use the ghp-import tool to commit them to the gh-pages branch and push the gh-pages branch to GitHub.
Use mkdocs gh-deploy --help to get a full list of options available for the gh-deploy command.
Be aware that you will not be able to review the built site before it is pushed to GitHub. Therefore, you may want to verify any changes you make to the docs beforehand by using the build or serve commands and reviewing the built files locally.
Organization and User Pages
User and Organization Pages sites are not tied to a specific project, and the site files are deployed to the master branch in a dedicated repository named with the GitHub account name. Therefore, you need working copies of two repositories on our local system. For example, consider the following file structure:
my-project/
mkdocs.yml
docs/
orgname.github.io/
After making and verifying updates to your project you need to change directories to the orgname.github.io repository and call the mkdocs gh-deploy command from there:
cd ../orgname.github.io/
mkdocs gh-deploy --config-file ../my-project/mkdocs.yml --remote-branch master
Note that you need to explicitly point to the mkdocs.yml configuration file as it is no longer in the current working directory. You also need to inform the deploy script to commit to the master branch. You may override the default with the remote_branch configuration setting, but if you forget to change directories before running the deploy script, it will commit to the master branch of your project, which you probably don't want.
(venv) (env311) PS D:\myProject\youname.github.io> mkdocs gh-deploy --config-file ../wiki/mkdocs.yml --remote-branch main