Commit Graph

102 Commits

Author SHA1 Message Date
Oleh Prypin
8dfef829b8 Enable <details> admonitions and nested codeblocks 2022-09-19 22:22:12 +02:00
Oleh Prypin
2a8ed44d9e Hooks feature: run plugin events from local Python files (#2978) 2022-09-19 22:18:38 +02:00
Oleh Prypin
4d4ef4c8f7 Add docs and tests for edit_uri_template option 2022-09-10 13:41:55 +02:00
Oleh Prypin
cd1135ee3e Fix remaining markdownlint issues, partly by replacing definition lists (#2914) 2022-08-07 14:46:10 +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
Simon Li
03b48936e3 Docs: site_url is optional (#2863) 2022-07-18 23:49:23 +02:00
Fullchee Zhang
c32fbe3376 Fix typo in configuration.md (#2844) 2022-05-18 00:20:24 +02:00
steven-terrana
82fcf3115a Support custom directories to watch when running mkdocs serve (#2642)
* adds a `watch` property to the `mkdocs.yaml` schema. Accepts a list of directories to watch.
* adds a `-w`/`--watch` command line option to `mkdocs serve` that can be passed multiple times
* options from `mkdocs.yaml` and CLI flags are combined
* the livereload server will also print the directories that it watches
* docs updated

Co-authored-by: Oleh Prypin <oleh@pryp.in>
2021-11-07 10:29:58 +01:00
Álvaro Mondéjar
b4fd3411f2 Fix mistake in docs about nav configuration (#2636) 2021-10-26 20:40:04 +02:00
Álvaro Mondéjar
8345850060 Add hint about -f/--config-file in configuration documentation (#2616) 2021-10-12 22:10:48 +02:00
Álvaro Mondéjar
4d1d1c1ba5 Fix various typos using codespell (#2549) 2021-08-20 17:06:01 +02:00
Oleh Prypin
e0ba6d7bd9 Tighten the docs and tests around site_url (#2506)
Some of the docs were accidentally reverted with other things, so I'm restoring them and adding a bit more.

Fixing an edge case: it is in fact possible to specify a URL with scheme and without netloc. Adding new tests to also catch that.
2021-07-17 03:11:30 +02:00
Oleh Prypin
b12804d97e Fix some spelling typos (#2489) 2021-07-13 19:07:59 +02:00
Oleh Prypin
ae556572d4 Revert "Ensure site_url and use_directory_urls do not conflict." (#2490)
This reverts commit b89ec5792e.

That commit claims to fix some bugs in interactions with `use_directory_urls`, but in fact there are currently no known unfixed bugs.
So there is no need to have that breaking change.
2021-07-12 22:26:04 +02: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
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
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
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
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
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
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
PoojaChandak
eba0bc51e1 Update configuration.md
Observed a few changes. Suggesting the same.
2020-10-27 14:31:04 -04:00
Jim Conner
2505a907f4 Add minimum search length configuration parameter.
Allow users to set their own minimum search term length.  Fixes #2014.
2020-03-16 14:35:06 -04:00
Jim Porter
a7c349cffa Update to lunr-languages v1.4.0; resolves #1729
This renames the Dutch language code to `nl`, the Japanese code to `ja`, and
adds support for Arabic (`ar`) and Vietnamese (`vi`).
2020-02-21 19:08:35 -05:00
Maximilian Albert
d07f5288da Fix typo 2020-02-11 14:23:24 -05:00
Dan Untenzu
f200a60060 Docs: Fix YAML syntax in examples
* Fix indentation
* Quote strings
2019-08-13 09:15:22 -04:00
Dan Untenzu
625e423b76 Docs: Clarify page title generation 2019-08-13 09:12:31 -04:00
Yeray Diaz Diaz
259c2b102b Use lunr.py for prebuilding indices (#1607) 2018-09-29 09:07:53 -04:00
Zrss
3642c4e03e Document --dev-addr instead of --dev_addr (#1638)
Fixes #1637.
2018-09-25 09:51:05 -04:00
coliff
b4b49a1f52 HTTPS Links 2018-07-19 11:53:56 -04:00
Waylan Limberg
34ef3ca6d0 Internal Refactor of Pages, Files, and Navigation (#1504)
Internal handling of pages, files and navigation has been completely refactored.
The changes included in the refactor are summarized below.

* Support for hidden pages. All Markdown pages are now included in the build
  regardless of whether they are included in the navigation configuration
  (fixes #699).
* The navigation can now include links to external sites (fixes #989, fixes #1373,
  & fixes #1406).
* Page data (including titles) is properly determined for all pages before any
  page is rendered (fixes #1347).
* Automatically populated navigation now sorts index pages to the top. In other
  words, The index page will be listed as the first child of a directory, while
  all other documents are sorted alphanumerically by file name after the index
  page (fixes #73 & fixes #1042).
* A `README.md` file is now treated as an index file within a directory and
  will be rendered to `index.html` (fixes #608).
* The URLs for all files are computed once and stored in a files collection.
  This ensures all internal links are always computed correctly regardless of
  the configuration. This also allows all internal links to be validated, not
  just links to other Markdown pages. (fixes #842 & fixes #872).
* An `on_files` plugin event has been added, which could be used to include
  files not in the `docs_dir`, exclude files, redefine page URLs (i.e.
  implement extensionless URLs), or to manipulate files in various other ways.

Backward incompatible changes are highlighted in the release notes included 
with this commit. Some notes regarding various decisions follow in no particular 
order:

This started out as the contents of the 'structure' dir from @tomchristie's 
work in #689.

All paths must be all Unicode all the time. When a byte string and a 
Unicode string are both passed to os.path (join ect) then returned value 
is always a byte string. Therefore, we need every path string to be 
Unicode. This ensures validation checks that and if the byte string uses 
the file system encoding, decodes it. For any other encoding, a 
validation error is raised.

Paths which start with a slash are assumed to be relative to the
docs_dir root. This behavior fixes #192. However, the slash not being
present in the output may surprise some users who are trying to create a
link relative to the server root when the mkdocs root is not at the
server root. The URLs available on a page are:

* Page.url is the url relative to the site_dir
* Page.canonical_url is the relative url joined with site_url or None if
  site_url is not defined (the default).
* Page.abs_url is the path component of the canonical url or None if
  canonical_url is None.

Note that new behavior is slightly different than before. Previously
abs_url ignored site_url and was always url with '' prepended. With the
new behavior, if site_url includes a subdir, that subdir will be
included in the abs_url.

When not on a server, there is no sensable "absolute_url" for a page.
Therefore, we shouldn't try to define one.

The thinking is that users generating docs to be browsed in the local
file system (`file://`) should leave the site_url setting unset, while
users who will be serving their docs from a server should be setting the
site_url. And if the site_url point sot a subdir of the server, the
abs_url will stil be absolute from the server root as it uses the "path"
of the canonical_url of the page.

Note that without the magical url context all URLs must be prepended by
`{{ base_url }}/` in the templates. While this requires a change in
third party themes, it is more consistent.

Links being ignored in raw HTML is now documented. Fixes #991.

All related tests that require temp dirs use the `mkdocs.tests.base.tempdir`
decorator. Note that any unrelated tests have not yet been updated. 
That can happen separately from this. The one test in 
`mkdocs.tests.structure.page_tests` (test_BOM) is unique enough to 
not use the decorator.
2018-06-28 15:08:17 -04:00
Joseph Lombrozo
a3e60f1385 Paths in config file are relative to the config file. (#1376) 2018-04-04 11:58:38 -04:00
Felix Eckhofer
71ebf353e6 Add support for GitLab repositories (#1435)
Note that the icons in the themes will not show up until FontAwesome is
updated to at least version 4.6 and/or an up-to-date version of the
upstream readthedocs css is imported.

This commit also fixes a slight documentation error regarding the
default value of `repo_name` and removes some tautological tests.
2018-03-15 09:31:51 -04:00
Waylan Limberg
dd7e2d910b Refactor search plugin (#1418)
* Use a web worker in the browser with a fallback (fixes #859 & closes #1396).
* Optionally pre-build search index (fixes #859 & closes #1061).
* Upgrade to lunr.js 2.x (fixes #1319).
* Support search in languages other than English (fixes #826).
* Allow the user to define the word separators (fixes #867).
* Only run searches for queries of length > 2 (fixes #1127).
* Remove dependency on require.js, mustache, etc. (fixes #1218).
* Compress the search index (fixes #1128).
2018-03-05 19:42:20 -05:00
Waylan Limberg
b9b37491e9 Update Python-Markdown links.
Python-Markdown has moved its documentation to
https://python-markdown.github.io/. See Python-Markdown/markdown#601
for details. The docs now point to the new location.

The Python-Markdown GitHub repo was also moved to
https://github.com/Python-Markdown/markdown so any links to the repo
have been updated as well.
2017-12-07 12:04:28 -05:00
Mahdi Majidzadeh
2990af2b63 Config docs should match YAML syntax (#1341) 2017-11-07 18:21:02 -05:00
Waylan Limberg
3f2ad4977f Fix search for third-party themes.
Added theme customization settings to the search plugin:

* include_search_page: Determines whether the search plugin expects the
theme to provide a dedicated search page via a template located at
`search/search.html`.

* search_index_only: Determines whether the search plugin should only
generate a search index or a complete search solution.

Themes should define these settings in their `mkdocs_theme.yml` config file.
Documentation has been updated as well. Fixes #1315.

Note: while we would not normally add new settings (features) in a point
(bugfix) release, this is fixing a regression for third party themes.
Therefore, it is a "bugfix" and appropriate for a point release.
2017-10-25 15:46:36 -04:00
Waylan Limberg
54a24ea89f Override site_url with dev_addr on local server.
When serving locally, the `site_url` actually is the `dev_addr`, so the
config should relfect that. Note that this override must happen after
config validation so that the proper defaults are evaluated for the
`dev_addr` setting. It cannot happen as part of "post_validation" as
there is no way to know the dev server is running within the config
validation (for example, the dev_addr may not be None as the user could
have set the `dev_addr` setting in their config file). Overriding it
from the serve command is the least invasive method and guarantees it
only happens when the local dev server is being run.

Also cleaned up `dev_addr` docs, which were missleading in some respects
and actually encouraged using the dev server over a network.

Fixes #1317. 404 Error pages now work on the loval dev server when
the `site_url` in the config points to a subdir.
2017-10-20 15:12:06 -04:00
Waylan Limberg
1477ea87be Some edit_uri tweaks.
* Improve documentation and ensure it matches actual behavior.
* Use `page.edit_url` not `config.edit_url` in mkdocs template (opps).
* Include whitespace between icon and label in mkdocs theme.
* Undefined `edit_uri` results in `page.edit_url = None` when not automated.
* Setting `edit_uri: ''` disables automatic edit_uri for GitHub & Bitbucket.
2017-10-19 14:47:17 -04:00
Jesse Kinkead
3f98d1deb3 Add "edit link" support to MkDocs theme.
Theme shows either a repo link or an edit link depending on whether
`edit_uri` is set. Also clarified documentation that this behavior is
dependant upon theme support. Fixes #1129.
2017-10-19 10:05:06 -04:00
Waylan Limberg
31e7c29784 Set 'search' as a default plugin.
Maintains better backward-compatability. Documentation updated, including
how to override the default. Also renamed the entry_point to 'search'.
The lib is still 'legacy_search'. When a new/better search plugin is
developed, the `search` entry_point will be pointed there so the default
behavior will inlcude the upgrade and a new `entry_point` will be added
('legacy_search') which points to the old plugin for those who really want
it.
2017-10-12 16:12:40 -04:00
Waylan Limberg
ffae0ef89c The Plugin API. (#1223)
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes #206
2017-10-01 16:48:47 -04:00
Waylan Limberg
75350da44c Theme refactor.
Themes now have `theme` objects, and theme specific configs.
Themes can inherit from other themes. Users (and theme authors)
can define custom static templates and variables.
2017-10-01 16:48:47 -04:00
Oscar Vasquez
aa9a2fdcea Added support for query and fragment strings in edit_uri 2017-05-12 23:42:27 -04:00
Terrell Russell
59026644f1 fix typo (#1185)
Fixes #1184
2017-04-04 10:07:20 -04:00
John Kerssens
82bcdbab69 Fix typos (#1181) 2017-04-04 10:07:02 -04:00
Waylan Limberg
1795d7655a System root ("/") is not a valid path for site_dir or docs_dir.
As neither setting can point at a child dir of the other, "/" would be an
invalid value for either setting. However, given its unique nature,
os.path.abspath does not follow normal bahavior of returning a string without
an ending slash when passed "/". Therefore, we need to special case it.

Fixes #1161.
2017-03-13 21:45:34 -04:00
Dougal Matthews
ecc0550c71 Correct the default for the remote_name config
See: https://github.com/mkdocs/mkdocs/blob/master/mkdocs/config/defaults.py#L119
2016-11-23 22:14:59 +00:00