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

Update docsy (hugo theme) git submodule #1295

Merged
merged 12 commits into from
Nov 8, 2022
Merged

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Oct 19, 2022

This PR updates our git submodule checkout of docsy to matrix-org/docsy@a0032f8, which is the latest current commit of google/docsy + some changes to locally-load fonts/css/js.

The previous version of docsy was >1 year old.


A few visual changes that I've noticed. These look fine and don't require fixing IMO:

(Table cell vertical text alignment) Before

image

After

image


(Breadcrumbs) Before

image

After

image


(Rate-limit/Auth text) Before

image

After

image


This change does not require a newsfragment.

Preview: https://pr1295--matrix-spec-previews.netlify.app

@anoadragon453 anoadragon453 marked this pull request as ready for review October 25, 2022 16:34
@anoadragon453 anoadragon453 requested a review from a team as a code owner October 25, 2022 16:34
@anoadragon453
Copy link
Member Author

I'm going to rework this PR to fix matrix-org/docsy#1.

@anoadragon453 anoadragon453 marked this pull request as draft October 27, 2022 15:44
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

clearing review while draft

Update to matrix-org/docsy@a0032f8, which has a
few changes on top of google/docsy.
Otherwise table-layout has no effect. I'm not sure why this broke,
possibly google/docsy#1255.
@anoadragon453 anoadragon453 marked this pull request as ready for review October 27, 2022 16:18
@anoadragon453
Copy link
Member Author

anoadragon453 commented Oct 27, 2022

This has been updated to the latest https://github.com/matrix-org/docsy/ (as of today). 343edc7 prevents all google fonts from loading while still loading Inter. The change also allowed removing one downstream change in our fork of docsy.

.github/workflows/main.yml Outdated Show resolved Hide resolved
run: |
cd themes/docsy
npm i
npm i --save-dev autoprefixer postcss-cli postcss
Copy link
Member

Choose a reason for hiding this comment

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

      npm i --save-dev autoprefixer postcss-cli postcss

this doesn't look right at all. This is modifying the package.json of docsy to say that these libraries are dev-time dependencies of docsy. If that's true, then it should be checked into git rather than done on the fly... but I don't think it's true.

The suggestion at https://github.com/google/docsy/#prerequisites is to do it in the Hugo site which uses docsy (ie, matrix-spec), not docsy itself. And it's already been done in matrix-spec: https://github.com/matrix-org/matrix-spec/blob/main/package.json#L21-L26

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, it seems I got myself in quite a confused state with the changes here. For clarity, note that we install docsy as a git submodule.

In the past, docsy used to have vendored submodules in its repo for bootstrap and Font Awesome. That is no longer the case with the current state of the theme. Now, bootstrap and font awesome are pulled in via npm.

So, in the past we got away with simply running git submodule update --init --recursive in the root of matrix-spec repo to get access to these dependencies. Now, we need to run npm i in the themes/docsy directory to get them.

I had gotten confused as scss files were failing to be built when running hugo serve. Then, after running npm i --save-dev autoprefixer postcss-cli postcss in themes/hugo, hugo serve worked! But what was actually the thing that made it work was installing the deps listed in themes/hugo/package.json.

So yes: this CI is wrong, and in addition our instructions to the build the repo need to be updated to include the extra npm i.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 3313b6a.

@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Disable loading any fonts from Google Fonts.
* Configure docsy to use the default bootstrap fonts instead of Google Fonts.
* See https://www.docsy.dev/docs/adding-content/lookandfeel/#fonts

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that no fonts are imported by bootstrap - bootstrap tries to load fonts from the system: https://getbootstrap.com/docs/5.2/content/reboot/#native-font-stack

$td-enable-google-fonts will disable fetching fonts from Google Fonts, and use system fonts instead. The list of system fonts is configured by $font-family-sans-serif below. The comment about "The list of fonts ..." tried to explain this, but I'll clarify it to mention $font-family-sans-serif explicitly. While the contents of $font-family-sans-serif looks like what bootstrap defines, it's originally from docsy's source code.

We have to override it (with Inter at the front) in order to load Inter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in a101159.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, the thing I really wanted to see here is a link to the place where td-enable-google-fonts is defined, which we still don't have. The interesting point here is that it's exposed by docsy rather than bootstrap.

I think my original suggestion is ok, with s/bootstrap/system/ ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes we definitely should add a link to that piece of documentation.

I think my original suggestion is ok, with s/bootstrap/system/ ?

Yes, this looks good on a re-read.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the modified suggestion in 4473805.

assets/scss/_variables_project.scss Show resolved Hide resolved
assets/scss/custom.scss Show resolved Hide resolved
@richvdh
Copy link
Member

richvdh commented Nov 1, 2022

Also: changelog please

This commit adds a bit of helper code to the top-level package.json to
always ensure that the `themes/docsy` submodule is checked out and that
its nodejs dependencies are installed. Thus, we can remove the need to
download git submodules directly. Instead they will be loaded when running
`npm i`.

We also don't need to load submodules recursively anymore, as docsy has
removed any submodules from its repo since the last time we updated the
theme.

The `--depth 1` bit of `git submodule update --init --depth 1` tells git
to only check out the latest commit of any submodules - saving bandwidth
and space.
Copy link
Member Author

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Also: changelog please

CONTRIBUTING.md mentions that:

Changes that do not change the spec, such as changes to the build script, formatting, CSS, etc should not get a news fragment.

So I'm not sure if this PR needs one?

run: |
cd themes/docsy
npm i
npm i --save-dev autoprefixer postcss-cli postcss
Copy link
Member Author

Choose a reason for hiding this comment

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

Right, it seems I got myself in quite a confused state with the changes here. For clarity, note that we install docsy as a git submodule.

In the past, docsy used to have vendored submodules in its repo for bootstrap and Font Awesome. That is no longer the case with the current state of the theme. Now, bootstrap and font awesome are pulled in via npm.

So, in the past we got away with simply running git submodule update --init --recursive in the root of matrix-spec repo to get access to these dependencies. Now, we need to run npm i in the themes/docsy directory to get them.

I had gotten confused as scss files were failing to be built when running hugo serve. Then, after running npm i --save-dev autoprefixer postcss-cli postcss in themes/hugo, hugo serve worked! But what was actually the thing that made it work was installing the deps listed in themes/hugo/package.json.

So yes: this CI is wrong, and in addition our instructions to the build the repo need to be updated to include the extra npm i.

@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that no fonts are imported by bootstrap - bootstrap tries to load fonts from the system: https://getbootstrap.com/docs/5.2/content/reboot/#native-font-stack

$td-enable-google-fonts will disable fetching fonts from Google Fonts, and use system fonts instead. The list of system fonts is configured by $font-family-sans-serif below. The comment about "The list of fonts ..." tried to explain this, but I'll clarify it to mention $font-family-sans-serif explicitly. While the contents of $font-family-sans-serif looks like what bootstrap defines, it's originally from docsy's source code.

We have to override it (with Inter at the front) in order to load Inter.

assets/scss/custom.scss Show resolved Hide resolved
assets/scss/_variables_project.scss Show resolved Hide resolved
run: |
cd themes/docsy
npm i
npm i --save-dev autoprefixer postcss-cli postcss
Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 3313b6a.

@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member Author

Choose a reason for hiding this comment

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

Done in a101159.

Comment on lines +8 to +10
"get:submodule": "git submodule update --init --depth 1",
"_prepare:docsy": "cd themes/docsy && npm install",
"prepare": "npm run get:submodule && npm run _prepare:docsy",
Copy link
Member Author

Choose a reason for hiding this comment

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

This is taken from docsy's docs: https://www.docsy.dev/docs/get-started/other-options/#for-an-existing-site

Unfortunately, we can't add comments to package.json files...

@richvdh
Copy link
Member

richvdh commented Nov 3, 2022

Also: changelog please

CONTRIBUTING.md mentions that:

Changes that do not change the spec, such as changes to the build script, formatting, CSS, etc should not get a news fragment.

So I'm not sure if this PR needs one?

CONTRIBUTING.md lies. We have an internal changelog section now for this sort of thing.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

thanks for doing all that digging. still a couple of nits.

README.md Show resolved Hide resolved
@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member

Choose a reason for hiding this comment

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

Ok, the thing I really wanted to see here is a link to the place where td-enable-google-fonts is defined, which we still don't have. The interesting point here is that it's exposed by docsy rather than bootstrap.

I think my original suggestion is ok, with s/bootstrap/system/ ?

assets/scss/custom.scss Show resolved Hide resolved
Copy link
Member Author

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

I've added a changelog entry as well (as .feature, which I thought fit best amongst the options, but feedback welcome!).

README.md Show resolved Hide resolved
@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes we definitely should add a link to that piece of documentation.

I think my original suggestion is ok, with s/bootstrap/system/ ?

Yes, this looks good on a re-read.

README.md Show resolved Hide resolved
@@ -37,8 +37,17 @@ $table-row-alternate: $secondary-lightest-background;
$table-row-default: $secondary-lighter-background;

/*
Opt to serve fonts locally by overriding web-font-path to be a non-google fonts URL.
This is only possible with our modified docsy theme: https://github.com/matrix-org/docsy
Disable loading any fonts from Google Fonts.
Copy link
Member Author

Choose a reason for hiding this comment

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

Added the modified suggestion in 4473805.

assets/scss/custom.scss Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

:shipit:

@anoadragon453
Copy link
Member Author

image

@anoadragon453 anoadragon453 merged commit fd41d9d into main Nov 8, 2022
@anoadragon453 anoadragon453 deleted the anoa/update_docsy branch November 8, 2022 17:29
clokep pushed a commit to clokep/matrix-spec that referenced this pull request May 3, 2023
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.

None yet

4 participants