Commit Graph

178 Commits

Author SHA1 Message Date
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
Jim Porter
15e31f7e68 Add support for customizing navigation bar styles in the mkdocs theme 2019-12-16 15:55:09 -05:00
Waylan Limberg
8c8f7bb672 Document that dot files are ignored. (#1925)
Also added a few additional clarifications about how MkDocs handles files in the docs_dir.

Fixes #1924.
2019-12-11 15:55:14 -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
Dan
b967d0184d Docs: Clarify supported header style
Only atx-style headers are supported for page titles,
not Setext styles.

Fixes #1837
2019-08-13 09:08:16 -04:00
Florimond Manca
a84b5a27df Fix broken readthedocs links 2019-06-23 18:58:11 -04:00
Waylan Limberg
9ae04213b9 Clarify mkdocs_theme.yml is ignored by theme.custom_dir
This only updates the documentation to better reflect actual behavior.
The config for `theme.custom_dir` is defined in the `theme` config
option of `mkdocs.yml`. Therefore, any `mkdocs_theme.yml` file within
a custom_dir is ignored.
2019-06-17 18:58:50 -04:00
devakker
32d2ed3bee Add warning to docs about usage of absolute paths in links.
Fixes #1757.
2019-03-07 09:52:08 -05:00
Terry Zhao
bebf3791aa docs(plugins.md): outdated docs (#1685) 2018-11-21 23:38:03 -05:00
Terry Zhao
1897177ab0 docs(plugins.md): fix typo
plugins.md:357

"The `post_template` event .." -> "The `post_page` event .."
2018-11-21 15:43:31 -05:00
Yeray Diaz Diaz
259c2b102b Use lunr.py for prebuilding indices (#1607) 2018-09-29 09:07:53 -04:00
Waylan Limberg
873b970f7f Update readthedocs theme with upstream (#1594)
Fixes #588 and fixes #1374.

# Some implementation notes:

## `include_homepage_in_sidebar` setting

Note that the homepage is always linked from the site_name above the 
search box. Therefore it does not need to also be in the nav tree.
In the upstream Sphinx theme, this is controlled when defining the 
toctree. However, Sphinx has a separate setting for identifying the 
"homepage". In MkDocs the homepage is identified as the first item in 
the `nav`. Therefore, without this setting you can't exclude the 
homepage from the sidebar like you can in Sphinx. With this setting we 
get feature parity.

## Nested sections

This output is a little weird as the section title is a link that does 
nothing when you click it. You need to click the `+` to expand the 
submenu. But that is what the upstream theme requires to work.
2018-09-27 13:19:17 -04:00
Zrss
3642c4e03e Document --dev-addr instead of --dev_addr (#1638)
Fixes #1637.
2018-09-25 09:51:05 -04:00
Waylan Limberg
e37d1c9b06 Example now matches actual usage.
As pointed out in #1633 the example of overriding a template block used an undefined block name. The example has been updated to use an actual block name.
2018-09-20 13:09:25 -04:00
Jon Dufresne
fc53f1932e Prefer https:// URLs where available 2018-09-18 11:21:13 -04:00
Waylan Limberg
1739e708f5 Fix typo 2018-08-27 13:08:20 -04:00
Waylan Limberg
f13bf0148a Remove reference to now deprecated template vars (#1610)
Fixes #1608.
2018-08-27 11:00:51 -04:00
c-bb
c16ea3ae77 writing-your-docs.md: fix typo 2018-08-24 10:52:52 -04:00
Waylan Limberg
c872896c49 Exclude README.md if index.md is present. (#1582)
Also properly sort READMEs.

Fixes #1580
2018-08-08 10:25:38 -04:00
coliff
b4b49a1f52 HTTPS Links 2018-07-19 11:53:56 -04:00
Waylan Limberg
06608e98a7 Add hljs_style config to mkdocs theme.
This is primarily to allow third party themes which inherit from the 
mkdocs theme (such as the bootswatch themes) to alter the code 
highlighting style. Previously all of the themes hosted their own 
highlighting styles, but now that we are using the CDN, it is easier to 
use a setting, which downstream themes can override.
2018-07-17 16:14:45 -04:00
Waylan Limberg
21449eeea8 Don't conflict with accessibility shortcuts.
In both built-in themes, the default next/prev shortcut keys were
changed from arrows to n/p as the arrows conflict with common browser
accessibility extensions.

In the mkdocs theme,  users can now configure the shortcuts to whatever
they want. Note that these config options are theme specific. The
readthedocs theme does not get these options as they are not available
on the parent theme.

Fixes #1502
2018-07-13 17:40:31 -04:00
Waylan Limberg
da92f72ec8 Add support for YAML meta data. (#1542)
If the frontmatter is surrounded by YAML deliminators, then it is parsed 
as YAML. Otherwise it is parsed as MultiMarkdown meta-data and each 
value is returned as a joined string.

Closes #1471.
2018-07-11 13:18:20 -04:00
Dmitry Shachnev
67630d888b docs: Replace RTD screenshot with a working one. (#1505)
The remotely linked image was removed in rtfd/readthedocs.org#3438.

Turns out we already have a local image we can use.
2018-07-05 16:35:18 -04:00
Waylan Limberg
2e9de0a297 Add a highlightjs config setting (#1533)
The built-in themes now include support for enabling/disabling
highlight.js. They also use a CDN to load the files. As the CDN only
includes 23 languages, a second setting to support more languages
is included.

If a user wishes to use a different tool for highlighting, they can
"disable" highlight.js and then use extra_css and/or extra_javasript
to add support for their tool of choice.
2018-07-05 13:47:16 -04:00
Waylan Limberg
a1b26ebabe Update documenation. 2018-07-03 15:26:28 -04:00
Waylan Limberg
fb5abb05a7 Document the builtin themes' lack of support for multi-level nav. 2018-06-29 16:07:03 -04:00
Waylan Limberg
fb9d9e36fb Add a level attribute to AnchorLinks.
This relimplements #1272 on the current code in master. Thanks to 
@funkyfuture for the original work on this.

Also removes some unused code after #1504.

Closes #1272.
2018-06-29 14:40:22 -04:00
Waylan Limberg
78ee87cc2e Document using custom domains with GitHub Pages.
Fixes #1496.
2018-06-29 11:14:57 -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
Waylan Limberg
a43163fc8d Document deploying to GH User/Org Pages.
Fixes #1291 and made possable by the work in #1376.
2018-04-04 15:55:40 -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
1c80f6d663 Better document plugin config
Fixes #1391.
2018-03-09 19:06:24 -05: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
Mario
a63d885cc8 Update Tables documentation (#1361) 2018-02-02 23:35:21 -05:00
Waylan Limberg
4b8687eee7 Refactor writing-your-docs.md (#1392)
Present the sections in a logical manner:

1. File Layout (where to save documents)
   * Configure Navigation...
2. Writing with Markdown
   * Supported extensions...

Added documentation for all included extensions. Also added some basic
information about Markdown; pointing to the implementation and rules.
Fixes #1385, fixes #316, and fixes #1172.
2018-01-23 16:29:14 -05:00
Alexandre ZANNI
8d4a883d89 change theme_dir to custom_dir 2017-12-29 08:42:24 -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
Waylan Limberg
dfb50c9160 Remove PyPI Deployment Docs.
PyPI's documentation hosting has been deprecated, and in fact, it
is no longer possable to upload documentation to PyPI. Therefore,
it is a disservice to our users to document how to deploy to that
service.

See the mailing list dicussions for the official announcement:
https://mail.python.org/pipermail/distutils-sig/2015-May/026327.html
https://mail.python.org/pipermail/distutils-sig/2015-May/026381.html
2017-12-07 12:04:28 -05:00
Matthew Schmoyer
4c7c69cd3a Fix typo with plugins module name 2017-11-29 21:58:35 -05:00
Robin Stevens
e46506b4ce Typo (#1357) 2017-11-27 11:58:04 -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
Waylan Limberg
4b8626c166 Improved theme config docs. 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