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

Upgrade readthedocs theme to v1.0.0 #2585

Merged
merged 24 commits into from Nov 7, 2021
Merged

Upgrade readthedocs theme to v1.0.0 #2585

merged 24 commits into from Nov 7, 2021

Conversation

Sparticuz
Copy link
Contributor

@Sparticuz Sparticuz commented Sep 23, 2021

I've gone through each release we've missed on the readthedocs theme, and updated the mkdocs fork. I've mainly kept to just implementing the changes as able and not rewrote functionality, (see Copyright in mkdocs fork vs upstream).

There are a few features that I've not implemented, due to them missing in our original fork, or just for ease of upgrading our fork:

  1. The ability to use a logo in place of site_name in base.html mkdocs fork, upstream Planned Done in 3cf33d9
    image
  2. Adding the version under the site_name in base.html, upstream, Not exactly sure what this version is pointing to, is it a git tag, or a config option, etc...? Might be related to Support multiple versions of docs. #193 Added support in 4c66a1a, but it just displays a string
    image
  3. Article comments in base.html under page.content, upstream.
  4. Build info in footer.html, upstream. I would like to implement this, but I believe I would need to add the mkdocs-git-revision-date-localized-plugin plugin
  5. Upstream has deprecated and removed the 'isogram' version of google analytics, but I wanted comment here before I also removed it. Keeping isogram for now

Fixes #2538
Fixes #2537
Fixes #2467
Fixes #1763
Fixes #2239

@Sparticuz
Copy link
Contributor Author

Sparticuz commented Sep 23, 2021

Refs at least these #2538, #2537, #2467, #1763, maybe more?

EDIT: #2239

This was moved to a package.json in upstream for version 0.5.0rc1, then upgraded to 3.6.0 in 0.5.2
@Sparticuz
Copy link
Contributor Author

Example of logo image, as well as style_nav_header_background
image

@Sparticuz Sparticuz marked this pull request as ready for review September 23, 2021 19:57
@Sparticuz
Copy link
Contributor Author

I've added support in 4c66a1a for

extra:
  version: "string"

It's just a string, doesn't pull anything from git.
image

Copy link
Contributor

@oprypin oprypin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all great work, thank you very much!

I have checked all the content of this pull request and it all makes sense and corresponds well to the actual changes in sphinx_rtd_theme.

I have only left small comments.

Now I'm just thinking how we can involve more people to try out this theme to make sure it actually works well on the frontend side.

mkdocs/themes/readthedocs/mkdocs_theme.yml Outdated Show resolved Hide resolved
mkdocs/themes/readthedocs/base.html Outdated Show resolved Hide resolved
mkdocs/themes/readthedocs/base.html Outdated Show resolved Hide resolved
mkdocs/themes/readthedocs/base.html Outdated Show resolved Hide resolved
mkdocs/themes/readthedocs/base.html Show resolved Hide resolved
mkdocs/themes/readthedocs/mkdocs_theme.yml Outdated Show resolved Hide resolved
This is being done in favor of using a css setting for `.wy-side-nav-search`

Update config_tests.py
@oprypin
Copy link
Contributor

oprypin commented Sep 27, 2021

I was strongly considering merging this PR with individual commits, but now I think it's slightly less organized for that. And, the main reason is that the commits contain large files which we may as well omit from storing in the repo. So I think I'll squash.

Also did you see that CI is failing?

@Sparticuz
Copy link
Contributor Author

I had kindof planned on it being squashed. Most of the commits are really unneeded, but it helped me visualize the changes by going release by release.

I did see the CI was failing, but I have no idea why. The error it's giving doesn't make any sense to me because the IP it's giving IS an IPv4 address.... It's also unrelated to any changes I made.

======================================================================
ERROR: test_IP_normalization (tests.config.config_options_tests.IpAddressTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/mkdocs/mkdocs/mkdocs/config/config_options.py", line 258, in run_validation
    host = str(ipaddress.ip_address(host))
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/ipaddress.py", line 53, in ip_address
    raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
ValueError: '127.000.000.001' does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/mkdocs/mkdocs/mkdocs/tests/config/config_options_tests.py", line 207, in test_IP_normalization
    value = option.validate(None)
  File "/home/runner/work/mkdocs/mkdocs/mkdocs/config/config_options.py", line 130, in validate
    return self.run_validation(value)
  File "/home/runner/work/mkdocs/mkdocs/mkdocs/config/config_options.py", line 260, in run_validation
    raise ValidationError(e)
mkdocs.config.base.ValidationError: '127.000.000.001' does not appear to be an IPv4 or IPv6 address

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Sep 27, 2021

It's possible that GitHub Actions upgraded their 3.8 version to a later patch that changed how IP addresses are normalized. See the "changed in" notes in https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address

@oprypin
Copy link
Contributor

oprypin commented Sep 27, 2021

OK! Yes, that fails on 'master', reproduced it here: https://github.com/mkdocs/mkdocs/runs/3723870272 and will fix it here: #2587

@oprypin
Copy link
Contributor

oprypin commented Sep 27, 2021

I have not decided when to merge it, and whether it's appropriate for a patch release, but this is definitely accepted.

@Sparticuz
Copy link
Contributor Author

I agree, I don't think this is a patch release. There were very few structural changes to the HTML, just a few things added. Mainly for the logo and version in the header, which are both optional additions. Actually the largest change was probably dropping Modernizr and replacing it with html5shiv. I guess, technically, that would have the possibility of breaking changes if someone were using the Modernizr CSS classes in their css-extra.css file.

For #2467, my PR only addresses the readthedocs theme. Would you like me to also add a fix for the mkdocs theme, or would you prefer a separate PR? (I could also take a look at updating that theme as well)

What are your thoughts on 3 and 4 above?

For 3, It doesn't appear that MkDocs supports comments, but that doesn't necessarily mean that someone couldn't use something like disqus with a override on the comments block? Adding this should be trivial.

For 4, That would add this stuff
image
to this area of our fork
image
IMO, this might be better as a separate PR, as it might need to add in a few plugins

@oprypin
Copy link
Contributor

oprypin commented Sep 28, 2021

I agree, I don't think this is a patch release. There were very few structural changes to the HTML, just a few things added.

Uhh I think there's some misunderstanding here. I was thinking whether it's appropriate for 1.2.3 (patch release) or 1.3.0. So which one do you mean?

For #2467, my PR only addresses the readthedocs theme. Would you like me to also add a fix for the mkdocs theme, or would you prefer a separate PR?

You're correct. Definitely a separate PR would be best. Thank you if you take up that work.

(3) and (4) I have not evaluated, but definitely let's not do those in this PR

@Sparticuz
Copy link
Contributor Author

I agree, I don't think this is a patch release. There were very few structural changes to the HTML, just a few things added.

Uhh I think there's some misunderstanding here. I was thinking whether it's appropriate for 1.2.3 (patch release) or 1.3.0. So which one do you mean?

I think it's a minor release, not a patch release.

@oprypin
Copy link
Contributor

oprypin commented Sep 28, 2021

@Sparticuz I would agree that the naming is unfortunate, but my use of it was correct as per https://semver.org/

But regardless, could you clarify your opinion, do you think it's appropriate for 1.2.3?

@Sparticuz
Copy link
Contributor Author

@Sparticuz I would agree that the naming is unfortunate, but my use of it was correct as per https://semver.org/

But regardless, could you clarify your opinion, do you think it's appropriate for 1.2.3?

Talking for the Theme itself, according to semver, it's a major release. Modernizr got removed, which removes a bunch of css classes that get added by the modernizr javascript. If a user was using those css classes, it would be a breaking change. (Also jquery went from v2 to v3, but I'm not sure jquery adheres to semver)

As for the version of MkDocs, it's a decision of whether or not a major update of a dependency justifies a major update of MkDocs itself. I'm not familiar with what Semver says for a breaking change in a dependency. (If we consider the readthedocs theme a dependency of MkDocs)

If you wanted, I could add in

theme:
  name: readthedocs
  modernizr: True

which would keep modernizr. I'm not familiar with the local dev server, but maybe a deprecation warning could be added if config.theme.modernizr was True. Then when MkDocs v2 is published, remove modernizr entirely.

@oprypin
Copy link
Contributor

oprypin commented Sep 29, 2021

Hmm well sorry for bringing up semver, because MkDocs doesn't actually follow it directly. It's more like "anything goes"."no major breaking changes"."no obvious breaking changes"

Anyway, from what you described (and I'm still not fully clear on it), seems like something could reasonably break, so then it's more like 1.3.0.
And to be fully clear again, it is fully out of the question to push it to 2.0.0, I was only considering 1.2.3 as the other option.

And thanks for suggesting a compatibility option, but uhh let's just rule that out entirely due to the big complexity.

@Sparticuz
Copy link
Contributor Author

Sparticuz commented Sep 29, 2021

Modernizr got removed, which removes a bunch of css classes that get added by the modernizr javascript. If a user was using those css classes, it would be a breaking change.

To explain a little further, modernizr adds a bunch of css classes to the (html or body tag, I forget which). This allows a developer to target a specific browser capability. For example:

.no-cssgradients .header {
  background: url("images/glossybutton.png");
}

.cssgradients .header {
  background-image: linear-gradient(cornflowerblue, rebeccapurple);
}

Since modernizer was removed, the .no-cssgradients and .cssgradients classes would be gone and the developers css would fail to apply as intended.

"anything goes"."no major breaking changes"."no obvious breaking changes"

Then yes, I agree with 1.3.0. I believe it's a big enough change to justify a minor version rather than a patch version.

@oprypin oprypin added this to the 1.3.0 milestone Oct 26, 2021
@oprypin oprypin merged commit fa52d3a into mkdocs:master Nov 7, 2021
@oprypin
Copy link
Contributor

oprypin commented Nov 7, 2021

Thank you very much!!

@marcelstoer
Copy link

marcelstoer commented Nov 7, 2021

@oprypin

I'm just thinking how we can involve more people to try out this theme

You could have tagged the people who created the issues this MR fixes (I am one of them). That way I'd have found out and could have helped testing before it was merged.

@Sparticuz thank you so much for all the hard work!

Looking forward to the next release.

@oprypin
Copy link
Contributor

oprypin commented Nov 7, 2021

Well it's not a problem to try it out now, certainly please do :)

@ajthealchemist
Copy link

ajthealchemist commented Dec 6, 2021

Example of logo image, as well as style_nav_header_background image

Hi. Why is this not working for me despite including the following lines in my mkdocs.yml file? The logo is in docs/img.

theme:  
   name: readthedocs
   logo: img/logo.png  

This is my mkdocs version:

mkdocs, version 1.2.3 from /home/username/.local/lib/python3.8/site-packages/mkdocs (Python 3.8)

@Sparticuz
Copy link
Contributor Author

This is my mkdocs version:

mkdocs, version 1.2.3 from /home/username/.local/lib/python3.8/site-packages/mkdocs (Python 3.8)

I don't believe this PR has been released yet. Should be in 1.3

@ajthealchemist
Copy link

I don't believe this PR has been released yet. Should be in 1.3

I see. Thanks for the clarification. I thought this feature was already released. That being said, is there a tentative release schedule? Can't wait for this feature! <3

@oprypin
Copy link
Contributor

oprypin commented Dec 9, 2021

Sorry, there is no tentative release schedule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants