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

Updating to PyData Sphinx Theme #1254

Draft
wants to merge 26 commits into
base: 1.1-dev
Choose a base branch
from
Draft

Updating to PyData Sphinx Theme #1254

wants to merge 26 commits into from

Conversation

choldgraf
Copy link
Contributor

@choldgraf choldgraf commented Mar 20, 2021

This is a PR to start updating the theme to the PyData Sphinx Theme. It is a basic "topbar-based theme".

For now, the PR is just a very basic theme switch to see how the new one looks "out of the box".

ToDo

  • I noticed one bug in the PyData theme when I switched over the theme which should be resolved in FIX: Updating the right sidebar width breakpoint pydata/pydata-sphinx-theme#341
  • Version selector - right now this doesn't exist in the pydata theme (see ENH: Add version switcher dropdown menu pydata/pydata-sphinx-theme#276 for one proposal)
  • Language selector - right now this doesn't exist in the pydata theme at all
    • ReadTheDocs selector support - another option is that we could try to use the RTD language/version switcher javascript, rather than hand-coding our own. This would entail figuring out the HTML that RTD needs to display this information and coding it into the theme.
  • Custom footer - So that we can display the privacy notice
  • Logo size - Logo should be bigger, how to do this given current logo ratio? @jpmckinney do you have thoughts?
  • Sidebar splash image - "Developed by Open Contracting" splash image needs to be in there somewhere

@jpmckinney
Copy link
Member

We can change the logo to PNG, and I think we have a new OCDS logo we can use.

Some things to keep:

  • Language switcher
  • Version switcher
  • Clear indication of version being viewed
  • Additional links (like the Data Review Tool)

Ideally we can keep a footer for the license and privacy policy.

I’ll double check if we need the OCP logo on every page or if we can just put it on the homepage.

I can have a look at our layout template to see what else we had overridden.

@choldgraf
Copy link
Contributor Author

@jpmckinney I added a few more todo items to the top comment, LMK if I'm missing some stuff

@choldgraf
Copy link
Contributor Author

@jpmckinney could you explain how the language and version switchers work on the current theme? I see that you've got a language_options block in there (https://github.com/open-contracting/standard/blob/1.1-dev/docs/_templates/layout.html#L29) but is that over-riding a RTD-theme-specific area?

@jpmckinney
Copy link
Member

@choldgraf
Copy link
Contributor Author

choldgraf commented Mar 30, 2021

ah nice - so that should be somewhat drop-inable into a template or something? Is that what you had in mind?

As an aside, this conversation sparked some renewed energy into figuring this out in the pydata theme itself, feel free to provide thoughts there if you like! pydata/pydata-sphinx-theme#360

@jpmckinney
Copy link
Member

Yes, that should work. I think adding the language and version as navbar items like in this pydata-sphinx-theme PR should be fine: https://github.com/pydata/pydata-sphinx-theme/pull/276/files

For the linked issue, I think the approach of a versions.json file makes sense for the general case. In our case we have a fairly bespoke setup already, so we're likely to only inherit HTML/CSS changes.

@cheekyshibe
Copy link

Can we add custom HTML blocks for specific pages (like html_sidebars).

  • Collect user feedback at the bottom of some pages and jump to somewhere such as a forum or open a mail to window
  • Not only do I use Google Analytics to collect website data, but I also need to insert more customized scripts

@choldgraf
Copy link
Contributor Author

@megchai is this question specifically for this repository's documentation? or about the pydata theme in general?

@cheekyshibe
Copy link

@MegChai is this question specifically for this repository's documentation? or about the pydata theme in general?

pydata theme :) Sorry for not clarifying

@choldgraf
Copy link
Contributor Author

choldgraf commented Apr 2, 2021

ah gotcha - think you could open an issue in the pydata theme repository if you have questions about it? This PR is for a totally different project, it just happens to be using the pydata theme :-)

@choldgraf
Copy link
Contributor Author

hey @jpmckinney - I just wanted to give a heartbeat on this. I'm trying to get pydata/pydata-sphinx-theme#355 finished and then make a release, which lays some groundwork for templating that we can re-use here. We've also merged a few other PRs in that theme that I think you'll like (e.g., collapsible side-bars) 👍

@jpmckinney
Copy link
Member

Nice! I appreciate the update.

@choldgraf
Copy link
Contributor Author

choldgraf commented Apr 16, 2021

I just released another patch to pydata sphinx theme to fix some bugs that were making this theme update look weird, and added the templates that I think should get this to work. Here's how the theme looks now:

image

A few questions for @jpmckinney

  • What do you think about the look and feel? Doesn't need to be perfect but it should be good enough for an MVP
  • I think that I got the version/language switching correct but let me know if that seems off
  • The error seems to be related to translations...could that be related to the theme change somehow?
  • I think the logo might be a bit tiny, but the ratio constraints us a bit. What do you think?

By the way, any chance you could activate ReadTheDocs previews for PRs? I find that it's really helpful in reviewing design and website builds.

@jpmckinney
Copy link
Member

jpmckinney commented Apr 20, 2021

By the way, any chance you could activate ReadTheDocs previews for PRs? I find that it's really helpful in reviewing design and website builds.

We don't use ReadTheDocs. We have our own system to deploy to https://standard.open-contracting.org/staging/BRANCH-NAME, but only if CI passes :)

I'm not sure why util/add_translation_notes.py is failing to find notes.mo (the last step of the build). I'll try locally. Update: I fixed the initial issue (notes.po not compiled). Now I need to update the script to work with the new theme.

Need to:

  • Knock-on effects
    • Update tests for new theme (uncomment old line in test_docs.py?)
    • Update ocdsindex for new theme
  • Internationalization
  • Features
  • Look and feel
  • Navigation
    • Review toctree (recommonmark previously nested sub-pages under in-page headings)
    • Interlink documentation websites via top navigation, e.g. Profiles (and OC4IDS), Tools (registry, flattening tool)
  • Miscellaneous
    • Fix TODOs in conf.py
    • Add <!--#include virtual="$BANNER" --> somewhere
    • Go through all templates
  • Look into allowing the theme to be customized via html_theme_options as before.
    • Use html_context, which has the same effect as html_theme_options.
    • analytics_id: See Fathom Analytics task.
    • display_version: Pending theme configuration.
    • root_url: Relevant to the version switcher. Pending getting that working.
    • short_project: Only relevant to mobile UI. Pending theme configuration.
    • copyright, etc.: These relate to footer.html
    'analytics_id': 'HTWZHRIZ',
    'display_version': True,
    'root_url': '',
    'short_project': project.replace('Open Contracting Data Standard', 'OCDS'),
    'copyright': copyright,
    'license_name': 'Apache License 2.0',
    'license_url': '{}/blob/HEAD/LICENSE'.format(repository_url),
    'repository_url': repository_url,

@jpmckinney
Copy link
Member

jpmckinney commented Apr 20, 2021

If my commits build, I'll test the switchers at https://standard.open-contracting.org/staging/theme Then, I'll discuss with our Head of Communications what CSS customizations I should prioritize.

Previously, we had forked a theme to customize it. Is it straightforward to customize the theme without forking? Is it all described in the theme's docs, or are there some generic Sphinx ways of customizing themes?

@jpmckinney
Copy link
Member

The very last step is failing (ocdsindex), but it still deploys the rest! https://standard.open-contracting.org/staging/theme/en/

@choldgraf
Copy link
Contributor Author

@jpmckinney in general the PyData theme is designed to be pretty customizable and flexible, so I'd say we try that first and then only fork if really needed, since that'll significantly increase the maintenance burden in my opinion

@jpmckinney
Copy link
Member

@jpmckinney in general the PyData theme is designed to be pretty customizable and flexible, so I'd say we try that first and then only fork if really needed, since that'll significantly increase the maintenance burden in my opinion

We'll be using the theme on 4 other documentation websites, which means if we edit the theme, we have to repeat it in 3 other repositories, which might exceed the maintenance burden of having a fork? What do you think?

That said, we already have script/update and script/diff scripts to align each website with https://github.com/open-contracting/standard_profile_template, so it might not be so bad to repeat changes 3-4 times.

@choldgraf
Copy link
Contributor Author

@jpmckinney ah that's good to know. I think that the approach is still the same - try to make the edits on one site, and see how nasty the customizations are. E.g., if it's just a CSS file that needs to be shared across sites, that could be centralized in one place and the other sites could pull from it, without creating a whole new theme.

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

Successfully merging this pull request may close these issues.

3 participants