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

[feature] Use Material theme for docs #1535

Merged
merged 7 commits into from
Feb 20, 2023

Conversation

daenney
Copy link
Member

@daenney daenney commented Feb 19, 2023

Description

  • I have no strong feelings about this change. Feel free to close it. I just thought I'd give it a go and see what it turned into
  • I haven't updated the Conda environment.yml yet but I'll go fight with it if this is a change you want to merge

This changes the theme to use Material with the slate (dark) theme and the accent colour set to orange. It also replaces the swagger plugin with one that works correctly with the Material theming.

I mostly tinkered with this because the Material theme provides a number of enhancement that make the docs easier for me personally to consume:

  • Content is in the middle of the screen, instead of pinned to the left (especially annoying on widescreen)
  • Scales nicer/is more usable at higher zoom levels
  • The document outline in the right hand column is much more obvious and accessible than tucked into the menu
  • With the built-in colours you can get closer to something that feels like the GTS style, and with a custom palette we can make it match perfectly in the future

Potentially useful in the future:

  • The social cards plugin/feature is nice to generate the fancy card previews
  • Maintains a Docker container (with all dependencies) that makes it easy to generate the website allowing it to be hosted anywhere

To try it locally:

$ python3 -m venv .venv
$ .venv/bin/pip install -r docs/requirements.txt
$ .venv/bin/mkdocs serve

It ends up looking like this currently:

Screenshot from 2023-02-19 23-06-25

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

@daenney
Copy link
Member Author

daenney commented Feb 19, 2023

You can preview the built version here now: https://gotosocial--1535.org.readthedocs.build/en/1535/

This changes the theme to use Material with the slate (dark) theme and
the accent colour set to orange. It also replaces the swagger plugin
with one that works correctly with the Material theming.
@f0x52
Copy link
Contributor

f0x52 commented Feb 20, 2023

ooh very nice! let me see if I can quickly port our colorscheme :)

@f0x52
Copy link
Contributor

f0x52 commented Feb 20, 2023

image

./mkdocs.yml:

  palette:
    scheme: gotosocial
extra_css:
  - assets/colors.css

./docs/assets/colors.css:

[data-md-color-scheme="gotosocial"] {
	--md-primary-fg-color: #fd6a00;
	--md-default-fg-color: #fafaff;
	--md-default-fg-color--light: var(--md-default-fg-color);
	--md-default-fg-color--lighter: var(--md-default-fg-color);
	--md-default-fg-color--lightest: var(--md-default-fg-color);
	--md-default-bg-color: #2a2b2f;
	--md-default-bg-color--light: #35363b;
	--md-default-bg-color--lighter: #3a3b41;
	--md-default-bg-color--lightest: #4d4e56;

	--md-typeset-color: var(--md-default-fg-color);
	--md-typeset-a-color: #66befe;
	--md-accent-fg-color: #89caff;

	--md-footer-bg-color: var(--md-default-bg-color);
}

.md-content {
	background: var(--md-default-bg-color--lightest);
}

@igalic
Copy link
Contributor

igalic commented Feb 20, 2023

is there a light theme for that as well?

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

image

./mkdocs.yml:

  palette:
    scheme: gotosocial
extra_css:
  - assets/colors.css

./docs/assets/colors.css:

[data-md-color-scheme="gotosocial"] {
	--md-primary-fg-color: #fd6a00;
	--md-default-fg-color: #fafaff;
	--md-default-fg-color--light: var(--md-default-fg-color);
	--md-default-fg-color--lighter: var(--md-default-fg-color);
	--md-default-fg-color--lightest: var(--md-default-fg-color);
	--md-default-bg-color: #2a2b2f;
	--md-default-bg-color--light: #35363b;
	--md-default-bg-color--lighter: #3a3b41;
	--md-default-bg-color--lightest: #4d4e56;

	--md-typeset-color: var(--md-default-fg-color);
	--md-typeset-a-color: #66befe;
	--md-accent-fg-color: #89caff;

	--md-footer-bg-color: var(--md-default-bg-color);
}

.md-content {
	background: var(--md-default-bg-color--lightest);
}

Amazing, thank you! I'll add that to the PR ❤️

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

is there a light theme for that as well?

There is. Material also allows you to enable switching between dark and light. However, since GTS itself doesn't have a light theme (that I know of) and my goal was to make it feel more as part of the project I haven't looked into that.

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

@f0x52 Your changes are awesome but it interacts a bit poorly with the Swagger UI (if you go into API Documentation > API Documentation). Things become a bit difficult to read. Any chance you can come up with a fix for that?

Co-authored-by: f0x52 <f0x@cthu.lu>
@f0x52
Copy link
Contributor

f0x52 commented Feb 20, 2023

@daenney ahh right, forgot to check that page. Will give it a look this afternoon.

@igalic there's currently no light GoToSocial colorscheme, but will also be something I'll look into soon(tm) (also #1214). When it's there for normal GTS it should be easy to port to the docs as well

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

For the Swagger UI, here's:

@tsmethurst
Copy link
Contributor

@f0x52 feel free to merge this when you're happy with it, it doesn't need to be before 0.7.1, since the docs at docs.gotosocial.org are always built from main anyways :)

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

Just one thing, I haven't updated the Conda environment yet. I'll try and figure that out today.

The dependencies for cairosvg and pillow can be satisfied on RTD, so
this adds them to our requirements.txt and enables the social plugin.
This generates opengraph and twitter card tags as well as fancy preview
images in GTS colour style for platforms that show that as part of link
previews.
@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

I think the Conda file is correct now. The dependencies listed make sense at least.

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

Card generation works now. So if you were to link the Federation page, in places that show the card previews you'll see [card

@f0x52
Copy link
Contributor

f0x52 commented Feb 20, 2023

Had to rename the theme back to "slate" because that's what https://github.com/Amoenus/SwaggerDark/ is hardcoded to detect dark mode 🙄
also re-added the "default" theme as a light-mode option (not GTS-colored for now). Good to merge I think!

@daenney
Copy link
Member Author

daenney commented Feb 20, 2023

Had to rename the theme back to "slate" because that's what https://github.com/Amoenus/SwaggerDark/ is hardcoded to detect dark mode roll_eyes also re-added the "default" theme as a light-mode option (not GTS-colored for now). Good to merge I think!

Ah well that's annoying. I might look into fixing that. But some other day.

If you're happy with the changes then lets do it 😄

@f0x52 f0x52 merged commit 40eea3b into superseriousbusiness:main Feb 20, 2023
@daenney daenney deleted the docs-spurcing branch February 20, 2023 22:09
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.

4 participants