1544 Commits

Author SHA1 Message Date
Waylan Limberg
bd167cf3f6 Bump version to 1.2.1 1.2.1 2021-06-09 13:20:07 -04:00
Christian Oliff
55e1cdf6ea fix example typo in release notes 2021-06-09 08:57:25 -04:00
Waylan Limberg
d3f8b242d3 babel is required for deployment 2021-06-07 11:26:06 -04:00
Waylan Limberg
2688a6d88d Ensure gh-deploy always pushes
This was a regression in behavior. I had missed that `push` and `force`
are two separate parameters of `ghp_import.ghp_import` in #2257.
2021-06-07 11:25:20 -04:00
Waylan Limberg
cd43e9a243 Bump version to 1.2 1.2 2021-06-07 09:44:23 -04:00
Oleh Prypin
b221df94fa Restore the ability to watch files through relative symlinks
Restore the ability to watch files through relative symlinks
(i.e. symlinks that have a non-absolute path as the target)

This was not fully fixed in #2427.

Switch from os.path.realpath to pathlib.Path.resolve
2021-06-04 10:42:38 -04:00
Waylan Limberg
769a926691 Correct documentation of on_pre_template event.
The behavior of this event has never changed. The documentation was simply
incorrect. Fixes #2308.
2021-06-02 13:01:21 -04:00
Waylan Limberg
80feaf03a4 Deprecate google_analytics config option.
A new replacement option (theme.analytics.gtag) was added to the built-in themes. Multiple different services could be offered under theme.analytics. At this time only support for gtag exists, but more could be added in the future.

Fixes #2252.
2021-06-02 11:02:01 -04: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
70f2cca09d Restore the functionality of watching files through symlinks
Watchdog doesn't support it directly but it happened to work everywhere except Windows

This is achieved by walking through the target directory, finding any symlinks in it, and watching their target too (+recursive walking of those too).

Important note: only symlinks that exist during startup will be taken into account, new ones aren't added.

Fixes #2425
Closes #2426
2021-06-01 14:24:43 -04:00
Ultrabug
8f5be54d85 utils: fix get_themes WARNING logs due to possible entry point
duplicates returned by importlib_metadata during tests

instead of using lists, we use and compare on sets

thanks to @oprypin for the heads up
2021-06-01 14:21:50 -04:00
Oleh Prypin
d9b957e771 Offset the local site root to the path of the site_url 2021-05-25 13:11:41 -04:00
Tom Klingenberg
044d8dd5e6 No exception if directory already removed
When `mkdocs serve` is shutting down, it cleans up after itself removing
the temporary directory created earlier.

Previously the condition whether the directory is to be removed was
unchecked and prone to a file system race condition (shared resource).

Given the directory is absent on the file-system while shutting down,
`mkdocs serve` threw an exception and exited in failure.

Change is to override the cause of the exception by preventing the
attempt to remove a directory that is already gone.

Closes #2420.
2021-05-25 11:58:53 -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
Waylan Limberg
d54419d54b Document deploying to local files 2021-05-18 13:13:05 -04:00
Waylan Limberg
5fc92b96e7 Documentation improvements
Clean up and improve the documentation following some recent changes.
Specificaly, ensure we consistantly document *two* required settings.
2021-05-18 13:13:05 -04:00
Waylan Limberg
aae31c88c9 Fix typo 2021-05-17 15:34:59 -04:00
Waylan Limberg
b89ec5792e Ensure site_url and use_directory_urls do not conflict.
The site_url config option is now required. If it is set to an empty
string, then use_directory_urls will be forced to false. Each will
issue a warning if not properly set. In a future release we may
raise an error instead.

Fixes #2189.
2021-05-17 09:44:28 -04:00
Waylan Limberg
e2a3480735 Remove hard dependency on lunr.py (#2402)
Begin deprecation of 'python' option of 'plugins.search.prebuild_index'.
2021-05-13 15:20:35 -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
Álvaro Mondéjar
775d506c63 Update IpAddress tests for Python3.9.5 2021-05-08 09:40:37 -04:00
Álvaro Mondéjar
a8ec4b64a3 Add 'es' themes translations
Document that, when a new translation is added for a theme, the documentation about the theme must be updated.
2021-05-07 09:57:19 -04:00
Oleh Prypin
59f7c0f4d2 Use f-strings instead of formatting 2021-05-07 09:51:53 -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
Oleh Prypin
34a425e5a5 Use paths already in context from create_media_urls
No need to recreate them from the config again.
2021-05-02 20:13:22 -04:00
Álvaro Mondéjar
d0202a512e Include hidden pages in sitemap
Closes #2177

* Instead of using nav items for sitemap entries rendering, `[file.page for file in pages]` is used.
* Rendered sitemap.xml content is properly formatted using 4 spaces for indentation.
2021-04-25 15:55:37 -04:00
Oleh Prypin
be69601e0c Fix wrapping of multiline strings for ColorFormatter 2021-04-25 15:51:48 -04:00
Waylan Limberg
cb85d48851 Improve CLI textwrapping
* Account for user's actual terminal width
* Skip wrapping if not in a terminal
* Preserve whitespace
* Avoid breaking long words and on hyphens
2021-04-20 10:24:30 -04:00
Pawel Borkar
749d1ff79a Update the LICENSE and the README 2021-04-19 14:44:21 -04:00
Waylan Limberg
ad8ec0c5ac Revert to logging.StreamHandler
The new ClickHandler was causing all log messages to be printed to the
test output. As it offered no real value and littered the test output,
we are reverting back to the logging.StreamHandler with no loss of
functionality. See #2364 for context.
2021-04-15 09:33:28 -04:00
Waylan Limberg
d038223e7a Identify homepage when use_directory_urls is False
Fixes #2363.
2021-04-14 21:35:31 -04:00
Waylan Limberg
6a694fd87b Refactor Logging and Error handling
Provide for better reporting to users, make for easier maintenance going forward, and allow future expandability. The following major changes were made:

1. The logging config is now defined in a way which will allow future expandability. For example, we could add additional levels of `strict` or `verbosity` (see  #1756) . All log messages are fed to a single log, which has two handlers (one for strict mode and one for verbosity). All level restrictions are defined per handler so that one restriction does not interfere with another. As filters do not have a level assigned to them, the previous count filter is now a nullhandler which counts all messages is receives (restricted only by level). The previous filter still exists (as a do-nothing instance) for any third-party plugins which called it. Those plugins should remove the call going forward.
2. A new exception `mkdocs.exceptions.Abort` was added. Rather than calling `SystemExit`, we now call `Abort`, which is a custom `click` exception that aborts with a readable error message and no traceback. Where appropriate, we catch errors, log them, and then call `Abort`. This allows us to remove all error handling from the CLI code and include it where errors originate from. Of course, as previously, unanticipated errors will still generate a traceback to allow debugging.
3. Log formatting has been improved. All log messages are now hard wrapped and indented for easier reading and color is used to identify each by type. Note that colors are only used to highlight errors, warnings and debug messages. Under normal operation with no issues, the user will not see any color.
2021-04-14 16:09:25 -04:00
Matthew McMillan
0da7f72478 Update lunr and lunr.js to 0.5.9 and 2.3.9 (#2359) 2021-04-10 20:04:44 -04:00
Waylan Limberg
6218e524b5 Correct docs if page template context var
Fixes #1736.
2021-04-10 19:31:14 -04:00
Waylan Limberg
d99419ac44 Ensure site_url ends with a slash
`urlparse(config['site_url']).path` can be empty if `site_url` does not end
in a slash. This ensures at least a slash is returned. Config validation
will add the slash if it is missing. Fixes #1785.
2021-04-10 18:43:13 -04:00
Hendrik Erz
eb31d4c0d7 Fix cut-off navigation in the ReadTheDocs theme
Fixes #2012.
2021-04-09 16:39:40 -04:00
Waylan Limberg
cc45748e72 Revert "Add --wait flag to serve command."
This reverts commit f73f221f1f.

It seems that the `wait` flag does not interupt the file watcher,
but simply delays builds. Therefore, a plugin which writes to the
`docs_dir` will still result in an infinite loop. That being the
case, the `wait` flag is not useful to us. See #2285.
2021-04-08 13:56:32 -04:00
Waylan Limberg
1beaf22245 Restore styling of tables in the readthedocs theme
Rather than including this is the JS form the upstream theme, the JS
has been included in a separate file `theme_extra.js` so that is is not
lost in a future update copied form upstream. Fixes #2028.
2021-04-07 20:22:08 -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
21b3d1d431 Ensure each instance of Config is unique
Replace the global variable `mkdocs.config.DEFAULT_SCHEMA` with
the function `mkdocs.config.defaults.get_schema()`. An instance is no
longer created on import (eliminating circular imports under certain
circumstances) and each call to `get_schema()` builds a new instance
of each object. Fixes #2289.
2021-04-05 18:48:59 -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
Oleh Prypin
fe6a389dae Exclude edge cases where get_relative_url depends on CWD (#2296)
When only one of the two passed paths starts with a slash, this function would produce results that depend on (and expose parts of) the actual current working directory.
In a similar manner, it was also possible to "break out" of the "current directory" by starting one of the paths with `../../..` etc.

Additionally, the fact that paths always end up being resolved relative to the current working directory made this function less efficient than it needs to be.
Fun fact: `get_relative_url('path_a', 'path_b')` actually ended up looking up how to get to `/current/working/directory/path_a` from `/current/working/directory/path_b`.

Luckily, none of these behaviors can ever actually come into effect (the function is always called without a leading slash and without paths deliberately trying to escape), but the fix is still good to reduce surprise.

*The actual fix* is that we make the leading slash ignored (or quite the opposite - we always add it).
Now when either of the two arguments try to go up higher than the top level, they just end up at the top level (e.g. `foo/../..` is effectively `.`), only then the "relative" calculation happens.
2021-04-04 15:21:16 -04:00
Andre_601
fd5a890578 Refactor Readme and use for long_description
Improve readme with a different structure and some link changes.

The landscape.io links have been removed as that project seems 
discontinued since April 2020.

With `long_description_content_type="text/markdown"` it is possible
to use Markdown text in the `long_description` meta-data field. Make sure
the latest tools (setuptools, wheel, twine) are installed before deploying.
2021-03-29 10:22:44 -04:00
Andre_601
41c9961de5 Link to GitHub discussions (#2334)
Related to #2256. Also remove link to unused IRC channel.
2021-03-25 13:39:42 -04:00
Masanori Matsumoto
aa20a9d086 Fix support for ja or jp in search. (#2178)
Add tinyseg.js included with lunr-languages v1.4.0. Fixes `MODULE_NOT_FOUND` error when lang is `ja` or `jp`.
2021-03-24 19:38:33 -04:00
Ginger Old
dd903d3092 Upgrade highlightjs to 10.5.0 for better code highlighting
Closes #2312.
2021-02-28 17:01:13 -05:00
Mick Orbik
4faa18d095 Added configuration for search indexing strategy (#2309)
Allows a user to supply a `indexing` configuration to the search
plugin which controls what to include in the search index (full,
sections, titles)
2021-02-21 15:05:14 -05:00
Ultrabug
b1f5dae055 files structure: move src_paths as a dynamic property, add remove
Plugins wishing to manipulate the Files structure have an append
method but can't dynamically work on src_paths since it's computed
once on Files instanciation

This commits allows plugins to manipulate Files trough append and
remove of file objects while not having to care about the src_paths
since it's now a dynamically computed property
2021-02-16 15:16:22 -05:00
Ultrabug
e65c7660ad config_options: display the name of the plugin failing validation
When a parameter value validation fails for a plugin the name of
the failing plugin is not displayed

This commit adds the name of the plugin in the error message for
completeness
2021-02-15 11:21:08 -05:00