You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking about how to reuse a custom MkDocs theme on multiple projects without copying files or using a git submodule, and it occurred to me that the jinja2.PackageLoader() could be used instead of the filesystem loader in build.py
This sounds great. It is on my mental list of things to do. I think at some point we want to move the current themes out into their own package (exceot maybe one or two builtin themes).
It would be great if packages could provide multiple themes. So, for example, you might have a light and dark version included in your my_mkdocs_theme package. then the bootswatch themes included in MkDocs could all come under one package. We could use some sort of path akin to Python like . - so then in the config you would have something like theme = my_mkdocs_theme.light but i'm not sure I like that.
We probably need to also attach the version of MkDocs they work with. This is a bit of a complicated issue to figure out too.
I think this is a great direction to take the idea - maybe we should start with the simplest way (as you describe) and build on it from there.
Finally, I'm not sure I like the idea of adding another config option. Maybe there is a way we avoid that as we already have theme and custom_theme.
It is probably also work getting @tomchristie's input on this, as I suspect he will have some thoughts on it.
Just an idea that could probably use some refinement.
As far as a config option, I only see the theme and theme_dir option. Perhaps depreciate theme_dir (still usable for a few versions) in favor of a custom_theme that is a path or package-dotted-path?
I'd generally prefer us to keep 'python'ness out of MkDocs where possible.
Yes, it's written in python, but long-term it's unnecessarily limiting if we tie in the ecosystem to that.
theme_dir may be simple, but that's also it's advantage - you don't need to understand a programming language's particular package repo, instead you just put your custom theme on the web somewhere and say 'hey folks, download this'.
Anyways, don't take anything I say as gospel, I might not have thought any of this through properly, but it does seem to me that introducing PyPI into the equation makes things more complicated, not less.
I'm conflicted, as I understand the motivation around avoiding python tooling but I don't want to invent our own packaging system. Ultimetly we would then need to teach a potential user this.
Is there a way we can make PyPI easier for our specific use case? A mkdocs subcommand that turns a directory of files into a package? Just thinking out loud here.
I'd suggest that custom, reusable themes will only be made by a smaller set of users that are perhaps more advanced but that might be naive.
Personally, I think adding a python package and still supporting the template_dir config option gets the best of both worlds: People can still simply copy a template directory, but advanced users can use a python package if they so choose.
Maybe I'm misunderstanding something - talk me through what the intention is here.
What problem does 'packaged' themes solve that downloadable themes don't?
If it's about wanting to point to an external entity rather than keeping it local then shouldn't we instead thing about a theme_url that can point at a zip file or similar. That'd allow us to point at git repos and/or versioned URLs if needed.
@tomchristie A theme_url is a great solution to what I'm thinking of.
The specific case I'm looking at is that I just wrote the documentation for docker-py, the Docker python client. docker/docker-py#375. Docker already has a custom mkdocs theme for their org, in the main Docker repo. I really just wanted to re-use that theme without having to copy the files.
I really like the idea of a theme_url. It avoids having to use python-specific tooling, and allows re-usable themes.
I'm also not keen on themes being spread over a random asortment of hosts.
I've got no issue with us having URLs like https://github.com/tomchristie/mytheme/archive/master.zip plus S3, bitbucket, or whatever else folks want to use. I'd be a million times happier with that then with repurposing the esoteric, obscure stack that is PyPI.
PyPI setup is a major pain in the ass usability wise. There's zero chance that I want our theme packaging go down that road. 😄
@d0ugal Either ways around we should try our utmost to ensure that we ain't gonna be making backwards incompatible changes to the context. Keep it simple and that should be something that we can make as a reasonable claim for the forseeable future.
"Versioning an interface is just a polite way to kill deployed applications" - Roy Fielding
Activity
d0ugal commentedon Oct 28, 2014
This sounds great. It is on my mental list of things to do. I think at some point we want to move the current themes out into their own package (exceot maybe one or two builtin themes).
It would be great if packages could provide multiple themes. So, for example, you might have a light and dark version included in your my_mkdocs_theme package. then the bootswatch themes included in MkDocs could all come under one package. We could use some sort of path akin to Python like . - so then in the config you would have something like
theme = my_mkdocs_theme.lightbut i'm not sure I like that.We probably need to also attach the version of MkDocs they work with. This is a bit of a complicated issue to figure out too.
I think this is a great direction to take the idea - maybe we should start with the simplest way (as you describe) and build on it from there.
Finally, I'm not sure I like the idea of adding another config option. Maybe there is a way we avoid that as we already have
themeandcustom_theme.It is probably also work getting @tomchristie's input on this, as I suspect he will have some thoughts on it.
micahhausler commentedon Oct 28, 2014
One possible way could be to specify in the theme the mkdocs versions, something like how setuptools does it:
my_mkdocs_theme/__init__.pyor a more picky case:
my_mkdocs_theme/__init__.pyMkDocs itself could assess if it's own
mkdocs.__version__matches themkdocs_allowedJust an idea that could probably use some refinement.
As far as a config option, I only see the
themeandtheme_diroption. Perhaps depreciatetheme_dir(still usable for a few versions) in favor of acustom_themethat is a path or package-dotted-path?d0ugal commentedon Oct 28, 2014
ah, I meant to write
themeandtheme_dir- the second is for custom themes typically under the same path as the mkdocs.yml.lovelydinosaur commentedon Oct 28, 2014
I'd generally prefer us to keep 'python'ness out of MkDocs where possible.
Yes, it's written in python, but long-term it's unnecessarily limiting if we tie in the ecosystem to that.
theme_dir may be simple, but that's also it's advantage - you don't need to understand a programming language's particular package repo, instead you just put your custom theme on the web somewhere and say 'hey folks, download this'.
Anyways, don't take anything I say as gospel, I might not have thought any of this through properly, but it does seem to me that introducing PyPI into the equation makes things more complicated, not less.
micahhausler commentedon Oct 28, 2014
@tomchristie After reading over the wiki, do you think re-usable, versioned templates are out of scope?
Is git submodules a better approach? I was really hoping to avoid the gnarliness of submodules.
d0ugal commentedon Oct 28, 2014
I'm conflicted, as I understand the motivation around avoiding python tooling but I don't want to invent our own packaging system. Ultimetly we would then need to teach a potential user this.
Is there a way we can make PyPI easier for our specific use case? A mkdocs subcommand that turns a directory of files into a package? Just thinking out loud here.
I'd suggest that custom, reusable themes will only be made by a smaller set of users that are perhaps more advanced but that might be naive.
micahhausler commentedon Oct 28, 2014
Personally, I think adding a python package and still supporting the
template_dirconfig option gets the best of both worlds: People can still simply copy a template directory, but advanced users can use a python package if they so choose.lovelydinosaur commentedon Oct 29, 2014
Maybe I'm misunderstanding something - talk me through what the intention is here.
What problem does 'packaged' themes solve that downloadable themes don't?
If it's about wanting to point to an external entity rather than keeping it local then shouldn't we instead thing about a
theme_urlthat can point at a zip file or similar. That'd allow us to point at git repos and/or versioned URLs if needed.micahhausler commentedon Oct 29, 2014
@tomchristie A
theme_urlis a great solution to what I'm thinking of.The specific case I'm looking at is that I just wrote the documentation for docker-py, the Docker python client. docker/docker-py#375. Docker already has a custom mkdocs theme for their org, in the main Docker repo. I really just wanted to re-use that theme without having to copy the files.
I really like the idea of a
theme_url. It avoids having to use python-specific tooling, and allows re-usable themes.d0ugal commentedon Oct 29, 2014
Ideally we need a theme version and the version of MkDocs it corresponds with. Storing this information only in the URL feels wrong.
I'm also not keen on themes being spread over a random asortment of hosts. I trust PyPI to be available and responsible.
However, it certainly is simpler.
lovelydinosaur commentedon Oct 29, 2014
Do we really need that ^?
I've got no issue with us having URLs like
https://github.com/tomchristie/mytheme/archive/master.zipplus S3, bitbucket, or whatever else folks want to use. I'd be a million times happier with that then with repurposing the esoteric, obscure stack that is PyPI.PyPI setup is a major pain in the ass usability wise. There's zero chance that I want our theme packaging go down that road. 😄
d0ugal commentedon Oct 29, 2014
We would want a MkDocs version unless the available context in templates is never going to change.
lovelydinosaur commentedon Oct 29, 2014
@d0ugal Either ways around we should try our utmost to ensure that we ain't gonna be making backwards incompatible changes to the context. Keep it simple and that should be something that we can make as a reasonable claim for the forseeable future.
12 remaining items
Implement mkdocs#179
Implement mkdocs#179
d0ugal commentedon Apr 24, 2015
Closing in favor of #476