-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Conversation
b8c5602
to
9417630
Compare
I'm going to rework this PR to fix matrix-org/docsy#1. |
There was a problem hiding this 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.
9417630
to
86a5d99
Compare
86a5d99
to
343edc7
Compare
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
run: | | ||
cd themes/docsy | ||
npm i | ||
npm i --save-dev autoprefixer postcss-cli postcss |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3313b6a.
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a101159.
There was a problem hiding this comment.
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/ ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Also: changelog please |
This reverts commit 5c52d4f.
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.
There was a problem hiding this 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?
.github/workflows/main.yml
Outdated
run: | | ||
cd themes/docsy | ||
npm i | ||
npm i --save-dev autoprefixer postcss-cli postcss |
There was a problem hiding this comment.
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
.
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
.github/workflows/main.yml
Outdated
run: | | ||
cd themes/docsy | ||
npm i | ||
npm i --save-dev autoprefixer postcss-cli postcss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3313b6a.
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a101159.
"get:submodule": "git submodule update --init --depth 1", | ||
"_prepare:docsy": "cd themes/docsy && npm install", | ||
"prepare": "npm run get:submodule && npm run _prepare:docsy", |
There was a problem hiding this comment.
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...
CONTRIBUTING.md lies. We have an |
There was a problem hiding this 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.
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
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/ ?
SCSS's documentation seems to suggest a similar style: https://sass-lang.com/documentation/syntax/comments
There was a problem hiding this 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!).
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
assets/scss/_variables_project.scss
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
After
(Breadcrumbs) Before
After
(Rate-limit/Auth text) Before
After
This change does not require a newsfragment.
Preview: https://pr1295--matrix-spec-previews.netlify.app