X Tutup
The Wayback Machine - https://web.archive.org/web/20210120023932/https://github.com/mkdocs/mkdocs/issues/2186
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible to use mkdocs as python module without the CLI #2186

Closed
moshir opened this issue Sep 10, 2020 · 2 comments
Closed

possible to use mkdocs as python module without the CLI #2186

moshir opened this issue Sep 10, 2020 · 2 comments

Comments

@moshir
Copy link

@moshir moshir commented Sep 10, 2020

Hi ,

is it possible to use mkdocs as a python package and generate documentations from python script, eg.:

import mkdocs
mkdocs.build(root="mkdocs.yml")
@gaborantal
Copy link

@gaborantal gaborantal commented Sep 10, 2020

HI!

You can try it yourself. I tried and no, you cannot use it as a package. There is nothing about it in the documentation, and also you cannot use it in the way you mentioned.

@waylan
Copy link
Member

@waylan waylan commented Oct 28, 2020

MkDocs is not designed with this use case in mind. However, it should not be impossible to do. You would basically need to replicate the code in __main__.py. Note that you need to load the config yourself, and then pass that to the build function. build won't do that for you. And then each of the CLI commands corresponds to a file in mkdocs/commands/ (build, serve, etc). With a little spelunking through the code, you should get something that works.

A word of warning though. As we don;t document the internal structure of the code, we don't guarantee backward compatibility. Any future release could completely break your code.

@waylan waylan closed this Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.
X Tutup