Repository navigation
Conversation
First shot at enabling installation of theme via a url, specified by the
config param `theme_url`.
`theme_url` should point to a zip file online. The zip file will be
downloaded and unzipped to the `themes` folder.
Note that as of current implementation, `theme_url` installs the theme,
but does not use it, i.e. the `theme` parameter needs to be specified in
order for the newly installed theme to be used.
A point of consideration:
- Should we check if the theme already exists? This is to prevent
downloading every single time we run `config.py`
- Don't install themes into the site-packages, we don't want to edit that. It should be considered read-only for us. Instead, download the theme to a .mkdocs directory in the same location as the mkdocs.yml - When installing a theme, use it like a custom theme would be used by adding it to the theme_dir. - Rather than include a zip file in the tests, create one on the fly that can be used - this makes it more flxible and clearer what is happening. - Compare the extracted theme with the original zipped theme - Use a pre-build theme zip for integration tests only
|
Moving this to the 0.13.0 milestone because I'm still not 100% sure on it and I want to try and get 0.12.0 out of the door in the next few days. |
|
Looks fairly straightforward - why not just use the ETag for caching? (aka: make a HEAD request and if it comes back clean with consistent cache information leave the zip directory alone) ... it does feel a bit heavyweight to do a full download + unzip for every build Though this can be a second pass upgrade as an improvement |
|
Good idea. It would be worth doing that for caching, that is probably the most technically correct way for fetching a HTTP resource. We also need to make sure that we don't error if the user is offline (and use the most recent version). |
|
I have two concern with this. First, I dislike that the theme is being inserted into the existing package. The next time I upgrade mkdocs. any themes downloaded this way will be wiped out. In my experience that is just bad practice. Second, I do not want the theme to be downloaded every time I build. Yes, I see some discussion about caching the download, but that discussion seems to assume that the download would still happen on any build in which a difference is detected between the cache and the remote file. What if updates to the remote file break my build? I want to be able to explicitly update the theme, or in the alternative, chose to continue to use an old version that I know works. Seems to me that #431 is a much better option with each theme being a separate package on the PyPI (Cheeseshop). You get version specificity and download/installation for free. |
|
The theme isn't inserted into the package. It should be added to a .mkdocs directory next to the config (inspired by tox). If it isn't, that is a bug. I agree, versioning is a concern. I had the same worry originally but at the time @tomchristie was against using python packaging for this. Honestly, I don't care for either approach (this or pypi) that much so I'd be welcome to new ideas. If nothing else, the download needs to be smarter for when you use 'mkdocs serve' #431 is regarding hosting built documentation on pythonhosted.org (it should be better worded). |
True, but I'm probably (?) lukewarm to anything other than plain ol' theme directories, so 😄 |
|
Oh right. I misread the source code. No themes are being copied to the package dir. Sorry about that. It seems to me this feature would be better suited to a CLI command as it should only ever need to be run once. Not sure why a setting needs to be used either. Once the theme is installed, it should be added to version control (assuming the rest of the docs are) and should never need to be fetched again. That is, of course, unless the user wants to update to a newer version of the theme. But the CLI command could handle that. Perhaps a theme could contain a data file (which starts with a dot so mkdocs ignores it) with the version and url that the CLI command could use. That way the user only ever needs to enter the full url on the command line the first time. From that point forward, it is all handled by the CLI command. Just a thought. |
I'm not sure you'd want to add a theme's files to your project's repository. You don't necessarily want to add the source of mkdocs - or any other dependencies - directly to your repo. Also, having themes represented by a URL is not necessarily a great idea, since it means that building the docs requires (for a I don't know what the solution to this is, but maybe there doesn't need to be one: as long as there's some (semi-) canonical place to put themes on your filesystem (maybe specified by an environment variable?), individual projects could probably come up with solutions that work for them. This could mean using a git submodule, or having a |
|
So, I'm still feeling a bit unsure about this. The problem with the current solution is that it isn't any better than: I'm now wavering back towards using Python packaging for this. It gives us a solid solution for most of our problems. The only downside I see is the complexity for theme authors, somebody that is well versed in frontend development but not Python packaging would be able to create a theme otherwise. However, I expect if we have a good example for people to copy, it wouldn't be that bad. If we go down that path, it would allow us to progress and we can perhaps worry about an easier to use approach later? |
|
I'll lay out my thoughts on this properly...
I'm not 100% convinced I see any great requirement for any kind of automatically install theme remotely behavior. I can see that it'd be nice to change a single line in the theme and have Would it make sense to defer work on this and start by:
We could then consider versioned packaging at a later date? |
@tomchristie What do you mean by "downloadable packages"? Just zip files that users download and extract into the project and then set |
Yeah, that was my meaning. |
With one exception. That assumes that people have zip/upzip tools installed on their system. Most Windows users do not (they don't have wget either) and while those commands are available on Linux, they are considered non-standard (tar.gz or tar.bz is usually expected) and must be installed by the user. The one exception is that if they have Python installed (which mkdocs requires of course), then they have Python's zip lib. Therefore, I think it is extremely beneficial for mkdocs to have its own theme install command if you are going that root. |
@waylan What were you thinking would be the appropriate location? Just |
I'm unsure. I suppose Whatever solution is chosen, it needs to work with tox, etc. For example a coding project may want to automate the building of their project's docs as a test. They would need to tell tox to run the following commands (the "checkspelling.sh" command it simply for demonstration purposes as a reminder that the test may do more than simply "build"): That needs to run in isolation, even in multiple environments on the same system. I think that if you use a dir within the project then the Personally, I understand why other projects have adopted PyPI as a distribution system. If feels like you will just be reinventing the wheel here. But is does feel weird to have a python package which is entirely non-Python. |
This sums up my thoughts entirely. We wouldn't be the first people to do this, but it is still a bit strange and a horrible experience for average front end folks. So, I'm somewhat torn about this as you can probably all tell. I'm going to try and state my motivations and see if it helps me more clearly see this.
With those motivations, I also would like to avoid just stripping out the current themes and telling users to go and fetch them. A bunch of people do use these themes, so that's a fairly nasty process. If we do that, I'd image a deprecation warning in So, I think, with all of the above. I have no interest in supporting something that requires us to implement our own packaging, however simple it is, I can see it getting complicated fast. So I think I'm going to abandon this PR, sorry @ngzhian for the change in direction. As for Python packaging? I'm not sure, it could work, I'm not entirely sure what it would look like yet. I'm going to take the discussion to #476 (and updated related issues). |
Would it make sense to allow parameterizing themes? The bootswatch themes appears to just be color swaps of the MkDocs theme, so if you could specify color swatches for the MkDocs theme, you'd probably be able to de-duplicate a lot of the current themes. |
|
@jimporter Yup, I think so. At the moment I do a search and replace to update them all which is somewhat tedious. Having said that, I don't want the infrastructure in MkDocs to do this build process, so I was waiting until I could move them out to a repo like mkdocs-bootswatch or similar. |
|
@jimporter I see, thanks - I guess that could work if somebody wants to make a theme that can be customised like that. For something like bootswatch themes I think it would require too many settings to be useful. However, it's worth considering as I've not looked to see how much difference there is between the bootswatch themes. |
This is based on the work in #221 and #410 which I've just rebased to fix a conflict.
I think I'm happy with this, but I want to take some time to think about it as it is a big feature change to add. I'm going to look into how other projects are solving similar problems and see if there is anything we can learn before landing this.