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

Support <script type="module"> and other attributes #3237

Merged
merged 13 commits into from
Jun 19, 2023
Merged

Support <script type="module"> and other attributes #3237

merged 13 commits into from
Jun 19, 2023

Conversation

oprypin
Copy link
Contributor

@oprypin oprypin commented Jun 3, 2023


See docs in the diff.

Try it out:

pip install git+https://github.com/mkdocs/mkdocs.git@refs/pull/3237/head

Particularly I'm hoping the frontend change of fiddling with defer in standard themes doesn't cause problems.


Frontend changes:

  • Stop using defer for all scripts
  • Update highlight.js to version 11.8.0

Small config features:

  • Fix propagating warnings from sub-items of ListOfItems
  • Strip trailing _ from config members, to bypass Python reserved words
  • Make it possible to create a subclass of SubConfig[T]

Refactors:

  • Consistently use tojson for pasting strings to JavaScript
  • More concise error message in SubConfig
  • Make TemplateContext typed, move utils.filters to utils.templates

The actual change:

  • Expand config.extra_javascript to support type, async, defer
  • Include *.mjs files into javascript_files()

oprypin added 10 commits June 3, 2023 15:52
Example of adding an `async` boolean option that can be read through `config['async']` or `config.async_`:

    class ExampleConfig(Config):
        async_ = Type(bool, default=False)
`SubConfig[SomeType]()` is now the preferred way to express `SubConfig(SomeType)`
but more importantly, it is now possible to subclass `SubConfig[SomeType]` for post-processing of the value.
The top-level template object `extra_javascript` gets soft-deprecated because it still reports only a list of plain strings.

Themes need to take action and pick up the new config keys from `config.extra_javascript` instead.
Copy link
Sponsor Contributor

@squidfunk squidfunk left a comment

Choose a reason for hiding this comment

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

LGTM from eyeballing, but I didn't run the code. Only some minor questions/adjustment (see comments).

docs/user-guide/configuration.md Outdated Show resolved Hide resolved
mkdocs/contrib/search/__init__.py Show resolved Hide resolved
mkdocs/utils/filters.py Show resolved Hide resolved
mkdocs/utils/filters.py Show resolved Hide resolved
mkdocs/utils/filters.py Show resolved Hide resolved
docs/user-guide/configuration.md Outdated Show resolved Hide resolved
mkdocs/contrib/search/__init__.py Show resolved Hide resolved
@oprypin oprypin merged commit 0440ddd into master Jun 19, 2023
30 checks passed
@oprypin oprypin deleted the mjs branch June 19, 2023 05:58
acodeninja added a commit to CPS-Innovation/digital-sop that referenced this pull request Jul 27, 2023
acodeninja added a commit to CPS-Innovation/digital-sop that referenced this pull request Jul 27, 2023
* Update dependency mkdocs to v1.5.0

* Correction to playbooks link

* Adapt base template to work with new extended script object

mkdocs/mkdocs#3237

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lawrence Goldstien <lawrence.goldstien@madetech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants