59 Commits

Author SHA1 Message Date
Oleh Prypin
c9cf11b941 Pin versions of black, isort, ruff 2024-01-26 21:13:01 +01:00
Oleh Prypin
9cd0cf4e17 Fix hatch environment 'docs' to use the local mkdocs checkout (#3518) 2023-12-14 22:14:55 +01:00
Oleh Prypin
4ad0dd16b2 Use hatch-mkdocs and hatch-pip-compile for docs deps 2023-12-03 13:11:33 +01:00
Oleh Prypin
aa10190a55 Migrate from Tox to Hatch as test runner (#2991) 2022-10-07 23:18:05 +02:00
Oleh Prypin
418d23a4da Actually depend on 'colorama' on Windows (#2987)
This was missed in #2606
2022-10-02 20:14:06 +02:00
Oleh Prypin
ff8552a57a Add tests for new class-based configs
The old-style tests are intentionally kept at config_options_legacy_tests.py
2022-09-25 20:03:54 +02:00
Oleh Prypin
8dfef829b8 Enable <details> admonitions and nested codeblocks 2022-09-19 22:22:12 +02:00
Oleh Prypin
cf8a07475f Deduplicate the nav specification with literate-nav 2022-09-18 18:47:54 +02:00
Oleh Prypin
a56ac6e051 Add plugin events that persist across builds in mkdocs serve
"One-time events" `on_startup(command)`, `on_shutdown`.

Their presence also shows that a plugin *wants* to persist across builds. Otherwise they will be re-created, to not change any existing behavior.
2022-09-11 23:06:34 +02:00
Oleh Prypin
df3739d519 Add a lot more type annotations, fix new type warnings (#2970)
(including some behavior changes, assumed to be no-op)

This is based on auto-generated annotations from "monkeytype".
2022-09-07 18:04:39 +02:00
Timothée Mazzucotelli
4ada758a79 Avoid importlib_metadata dependency since Python 3.10 (#2959) 2022-09-01 23:44:35 +02:00
Oleh Prypin
f7307905d4 Drop support for Python 3.6. It's EOL 2022-08-23 21:29:53 +02:00
Oleh Prypin
90e85f9fae Enforce 'mypy' type checker, add py.typed (#2941) 2022-08-21 18:51:17 +02:00
Oleh Prypin
2a06ece80a Synchronize requirements files, reduce deps installation for lint (#2943) 2022-08-21 17:15:46 +02:00
Oleh Prypin
f79b34d174 Move plugin events docs into source code + refactor
* Create real (no-op) methods for each event in the base class.
* Refactor event dispatcher to not check for methods' existence, instead just call them.
* Move documentation from Markdown into docstrings of these methods.
* Activate the 'mkdocstrings' plugin.
* Use 'mkdocstrings' to insert documentation from those docstrings into the site.
2022-08-14 18:33:36 +02:00
Oleh Prypin
5b87ba9971 Drop py36 integration tests 2022-08-14 18:21:10 +02:00
Oleh Prypin
a66a7ba474 Enforce 'isort' formatter 2022-08-08 21:42:39 +02:00
Oleh Prypin
58a99e5b38 Enforce Black formatter 2022-08-07 20:25:35 +02:00
Oleh Prypin
f5777a915a Docs: add a diagram with relations between all the plugin events (#2387) 2022-08-07 15:05:44 +02:00
Oleh Prypin
22af92c874 Migrate docs from "admonition" to "callouts" extension (#2684)
The result is exactly equivalent, just different syntax -- one that doesn't look weird in vanilla Markdown parsers such as on GitHub.
The output HTML before/after is equivalent , other than adding `<p class="admonition-title">Block</p>` in two cases, which I hid with CSS.

This also contributes to fixing the currently-present markdownlint MD053 violations, as it can't scan inside admonitions.

Add 'markdown-callouts' to dependencies and bump Markdown dep.
2022-08-06 17:35:36 +02:00
Ultrabug
dd7986ff7b Requirements: pin Markdown version to <3.4 (#2893) 2022-07-19 09:09:11 +02:00
Oleh Prypin
ec9b583b02 Bump importlib_metadata to at least 4.3 to support Python 3.10 (#2802) 2022-03-26 10:43:00 +01:00
Álvaro Mondéjar
747320fff3 Pin MarkupSafe to <= 2.0.1 to support Jinja2 in minimum requirements (#2778) 2022-02-26 13:57:00 +01:00
Álvaro Mondéjar
7e69cc5f68 Declare support for Python 3.10 (#2617)
* Bump minimum Jinja2 requirement
2021-12-30 23:17:56 +02:00
Álvaro Mondéjar
cc88b5a680 Reuse Jinja2 tojson builtin filter (#2713)
Also drop Markupsafe from requirements
2021-12-30 23:06:33 +02:00
Oleh Prypin
ba83f90298 Depend on 'colorama' on Windows to fix color output in terminal (#2606)
Adding the explicit dependency, because

1. 'click' prior to v8.0 did not have this dependency, it was used "only if present"
2. We *are* importing it, let's declare it as such
2021-10-11 19:15:34 +02:00
Waylan Limberg
57b5ccd7d6 Add support for Configuration Inheritance
* Support dict only markdown_extensions config
* Support dict only plugin config
* Remove explicit conversion to Unicode as PY2 is no longer supported.
* Refactor yaml_load so that is can recursively call itself.

Fixes #2218.
2021-06-01 14:50:00 -04:00
Oleh Prypin
a444c43474 Reimplement livereload
This discards the dependency on 'livereload' and 'tornado'. This implementation is based on stdlib http.server and is much smaller, while not being a downgrade in any way.

This fixes #2061: multiple file changes no longer cause the site to repeatedly rebuild.
It also makes reloads much more responsive; they're "instant" rather than being on a 1-second polling interval or such.

Each HTML page gets JavaScript injected into it (like before) but now, instead of connecting to WebSocket, it requests a long-polling endpoint, which blocks until a newer version ("epoch") of the site is available - then the page knows to reload itself. After a minute without events, the endpoint will just return the unchanged epoch (to avoid timeouts), then the page requests the same endpoint again. The "downtime" in between requests is not a problem because these are not events that need to be received in real time; the endpoint can instantly report that the latest version is newer than the one the page identified itself as.

The reason to replace WebSocket isn't that it's bad or something, just that stdlib doesn't have it. But long-polling works completely fine here too.
2021-05-25 10:16:31 -04:00
Oleh Prypin
23e205153f Replace use of deprecated alias jinja2.Markup
- use `markupsafe.Markup` directly instead.

Note: the choice of version is to match https://github.com/pallets/jinja/blob/2.10.1/setup.py
2021-05-13 10:38:33 -04:00
Ultrabug
e1b77ab66e Support theme localization
A framework for translating themes as been added, which includes:

1. Use of Jinja's `i18n` plugin for translating phrases in templates (not page content).
2. A French translation of the built-in themes (contributions in other languages are welcome).
3. A new `theme.locale` option to define the locale/language of the site.
4. The search plugin uses the value of `theme.locale` as its default 'lang'.
5. Third party themes may chose to use the framework (use is optional).
6. A documented workflow for translating MkDocs built-in themes.
7. Custom tooling for use by translators and theme devs.

The dependencies are not installed by default and are not needed to use MkDocs without translations. However, for anyone who wants to make use of the features, `pip install mkdocs[i18n]` will install all necessary dependencies.

Relates to #211.
2021-05-06 14:30:21 -04:00
Waylan Limberg
24f7e12efb Replace pgk_resources.parse_version with packaging.version.parse
This removes the final dependency in pkg_resources. Closes #2347.
2021-04-06 16:26:59 -04:00
Waylan Limberg
ec64ab40a5 Replace pkg_resources with importlib_metadata
This is using the new "selection interface" ( by calling `entry_points` with
the `group` parameter) that is being introduced in `importlib.metadata` of
Python 3.10 (currently in alpha). While the backport (`importlib_metadata`)
introduced the same change in version 3.6, various improvements have been made
up through the current release (3.10). Therefore we require
`importlib_metadata>=3.10` for all supported versions of Python (3.6-3.9).
2021-04-06 11:51:45 -04:00
Waylan Limberg
a118183f5e Refactor docs (#2344)
The homepage has been redesigned. The "Installation" and "Getting Started" sections were moved to their own respective pages. Then, the homepage was restyled so that the list of features appear as a grid of cards.

The developer specific pages were moved to a new section: `dev-guide`. Any old URLs redirect to the new ones.
2021-04-04 16:14:29 -04:00
Waylan Limberg
f4de3c7387 Support Environment Variables in config file
Environment variables can be assigned as values in the configuration
file using the !ENV tag. Resolves #1954.

The behavior is defined in the third-party package pyyaml_env_tag:
https://github.com/waylan/pyyaml-env-tag
2020-12-23 13:02:21 -05:00
Waylan Limberg
c7d86d4989 Support PY39 and drop PY35 (#2260)
PyYAML 3.13 fails to install on PY3.9 on MacOS. The next public release was 5.1.
2020-12-21 16:31:38 -05:00
Waylan Limberg
5c2b4f1353 Update ghp_import dependency to 1.0
Replace vendored (and modified) copy of ghp_import with dependency on
upstream library. As of version 1.0+ ghp_import includes a Python API.

MkDocs can now benefit from recent bug fixes and new features, including the following:

* A `.nojekyll` file is automatically included when deploying to GitHub Pages.
* The `--shell` flag is now available, which reportedly works better on Windows.
* Git author and committer environment variables should be respected.

Resolves #2170 and resolves #1383.
2020-12-21 14:02:02 -05:00
Jim Porter
37e645d623 Use toc_tokens to generate the TOC
This patch improves the consistency of TOC levels, so now the level is always
equal to the N in the `<hN>` tag. It also allows users of the MkDocs theme to
set the navigation depth to show in the TOC panel (defaulting to 2).
Resolves #1910 and resolves #770.
2020-02-17 17:27:12 -05:00
Waylan Limberg
61105ce56d Update min Markdown version to 3.0. 2019-12-23 15:54:26 -05:00
Waylan Limberg
399f8428b8 Switch from nose to unittest.
The nose docs state:

> Nose has been in maintenance mode for the past several years and will
> likely cease without a new person/team to take over maintainership.
> New projects should consider using Nose2, py.test, or just plain
> unittest/unittest2.

As we aren't using any of nose's features, its easiest to switch
to the standard lib unittest.

Also clean us various warnings as Nose was hiding them:

* warn => warning
* assertRegexpMatches => assertRegex
* Ensure 'new' files are closed.
* Cleanup tempdir
* assertEquals => assertEqual
2019-12-23 15:24:06 -05:00
Waylan Limberg
2491c1433a Update min dependency to Jinja 2.10.1.
Jinja 2.10.1 patched a security valnerability. See the release notes here:
https://github.com/pallets/jinja/blob/master/CHANGES.rst#version-2101

Closes #1780.
2019-12-20 15:01:02 -05:00
Waylan Limberg
c9032bd6bf Drop Python 2.7.
* Disable Linkchecker Test.
* Switch to unittest.mock in standard lib.
* Apply `pyupgrade --py3-plus`.
* Note: Using `builtins.open` mocks all calls to `open`, including test setup
(such as in `load_config`). Whereas, `path.to.namespace.open` only mocks
`open` in that namepsace. This all worked differently when we used `io.open`
as that wasn't a builtin to begin with. 
* Add a helpful error msg for PY2 users who use non-standard install methods.

Closes #1926.
2019-12-20 08:44:07 -05:00
Waylan Limberg
7c0d0b7624 Add official support for PY37. (#1545)
* Use Python 3.7-dev in Travis until they add official support for PY37.
* PY37 requires PyYAML 3.13+.
2018-07-12 15:24:19 -04:00
Waylan Limberg
e57e2269d9 Improve Markdown extension error messages.
Fixes #782. Note that we mock Markdown in the tests to ensure those
tests are not using Markdown to validate the extension names. We don't
mock Markdown in the tests which we do want Markdown to validate the
extension names.

Also ensure project-min has all relevant extensions.
2018-04-06 15:26:57 -04:00
Waylan Limberg
d6449f9080 Drop official support for Python 3.3.
Also up tornado version to >=5.0. Fixes #1427.
2018-04-03 15:49:15 -04:00
Waylan Limberg
5ee6600c95 Link to GitHub issues from release notes.
Uses the `mdx_gh_links` Markdown extension. Fixes #644.
2018-03-09 14:08:24 -05:00
Waylan Limberg
9e051a3636 Remove more PY26 specific code. See #165 & #688. 2017-10-01 16:48:47 -04:00
Waylan Limberg
3c8a1fccca Up livereload version to >=2.5.1. (#1122)
This ensures older pyinotify versions don't break the livereload server.
Fixes #1106.
2017-01-08 17:53:08 -05:00
Dougal Matthews
cc1c9a3adb Remove external themes from MkDocs
This change removes the dependency on mkdocs-bootstrap and mkdocs-bootswatch.
It also updates all references in the code. The only remaining connection is
when a user specifies one of these themes but they are not installed they get
slightly helpful error.
2016-03-01 10:53:02 +00:00
Dougal Matthews
71de07cdaf Lower the required Click version to 3.3 2016-01-29 17:21:12 +00:00
Dougal Matthews
4cb864a66f Limit the version of mock for Python 2.6 2015-07-10 09:48:57 +01:00