300 Commits

Author SHA1 Message Date
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
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
7e06ca68d1 Add multi-level nesting support to sitemap.xml
Fixes #1481.
2018-05-09 11:55:58 -04:00
Waylan Limberg
e5c2459fdf Warn users deploying with older version. (#1467)
Fixes #640.
2018-04-12 16:08:33 -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
Joseph Lombrozo
a3e60f1385 Paths in config file are relative to the config file. (#1376) 2018-04-04 11:58:38 -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
35f6412b51 Update release-notes
Whoops, forgot to add this in 71ebf35.
2018-03-16 15:34:42 -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
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
Anatoli Babenia
0dce2b2b9e Expand {sha} and {version} is user commit message (#1410) 2018-02-22 09:31:19 -05:00
Waylan Limberg
a793eede8b Update release notes. (#1403) 2018-02-06 14:58:45 -05:00
brandongc
d00a8e52f5 Refactor utils.copy_media_files for more flexibility (#1370) 2018-01-05 14:01:34 -05:00
Brendan Abbott
ab0b5824d0 Update Release Notes regarding Search plugin. (#1364)
Outline that the path where the search index is written to has changed slightly from `mkdocs/` to `search/`
2017-12-18 11:22:10 -05:00
Waylan Limberg
269190c9aa Up version to 0.17.2. (#1350) 2017-11-15 10:34:02 -05:00
Waylan Limberg
b504e14501 Correct extra_* config setting regressions.
The warning for missing files should only be issued if the config
setting is empty. The warning only exists because we disabled
autopopulating of the settings. Autopopulating only used to run
when the setting was empty so the warning is not nessecary if
the setting has been populated.

Given the above, no string comparisons need to be made as we
only need to check if any files exist when empty. Therefore, we
don't actually need to normalize paths. As we are no longer
modifying users' strings, they can again put any string in their
config, such as URLs of CDNs.

Fixes #1335 & #1336.
2017-11-01 15:24:52 -04:00
Waylan Limberg
109e517f7f Upped version to 0.17.1. 2017-10-30 14:45:58 -04:00
Waylan Limberg
f5b398c145 Support repo_url with missing ending slash.
Also broke up `edit_uri` tests into individual methods and added a few
missing senarious. Fixes #1321.
2017-10-27 13:11:00 -04:00
Waylan Limberg
fd04285432 Add length support to toc.
This could be useful in templates. Fixes #1325.
2017-10-27 11:38:40 -04: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
d393158445 Version to 0.17.0
Also made a couple adjustments to "documented" Python versions.
2017-10-19 19:01:36 -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
84906a7a6c Updated release-notes.
Added last missing item in list of changes.

Changed version from 1.0.0 to 0.17.0 as that will be the next release.
2017-10-18 11:19:26 -04:00
Waylan Limberg
b5f33bf1ea Partially Revert "Remove deprecated autofill of extra configs."
This partially reverts commit f90c44a20d.

The behavior is still deprecated, but a warning is now issued to inform
the user that the "extra" files not listed have been ignored.
2017-10-13 19:29:33 -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
66a282c44c Update release notes. 2017-10-04 14:24:13 -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
Waylan Limberg
b9af8b1fba Refactor Markdown handling. (#1180)
All Markdown handling is now contained within the `Page` object, which
external code no longer needs to know the internals of.
A slightly different approach to the work started in #713.

Include the multimarkdown meta-data parser from docdata
See: https://github.com/waylan/docdata

Tests have been updated. However, as noted in #713, they could use
some refactoring. The existing tests all pass. We can leave refactoring
as a seperate matter from this.

Closes #713.
2017-10-01 16:48:47 -04:00
Waylan Limberg
b4cc6c3367 Removed special error message for mkdocs-bootstrap and mkdocs-bootswatch themes.
Related to #1168.
2017-10-01 16:48:47 -04:00
Waylan Limberg
8af4b64435 Release-notes cleanup. 2017-10-01 16:48:47 -04:00
Waylan Limberg
74980574a9 Removed workaround for missing main.html in themes.
Related to #1168.
2017-10-01 16:48:47 -04:00
Waylan Limberg
6b1f014c2a Remove deprecated template variables.
Related to #1168.
2017-10-01 16:48:47 -04:00
Waylan Limberg
db56c73795 Remove support for deprecated pages config.
Related to #1168.
2017-10-01 16:48:47 -04:00
Waylan Limberg
99936b803b Remove previously deprecated json command.
Closes #481.
2017-10-01 16:48:47 -04:00
Waylan Limberg
418965977f Drop support for Python 2.6.
MkDocs most likley will no longer run on Python 2.6. All relevant tests
have been removed. Closes #165.
2017-10-01 16:48:47 -04:00
Waylan Limberg
931e8d0ab8 Bumped version to 1.0.dev 2017-10-01 16:48:47 -04:00
Waylan Limberg
f8c3433b3d Bump version to 0.16.3. 2017-04-04 17:56:12 -04:00
Waylan Limberg
4769f0054e Start release notes for 0.16.3 (#1192) 2017-04-04 14:13:40 -04:00
Waylan Limberg
8c9773dc36 Version bump to 0.16.2 2017-03-13 21:59:01 -04:00
Waylan Limberg
7a8159738f Updated release-notes. 2017-03-13 21:45:34 -04:00
Dougal Matthews
f5e9339579 Bump the version and add release notes 2016-12-22 09:06:58 +00:00
Dougal Matthews
088828b227 Bumping the Mkdocs Version to roll a release 2016-11-04 10:48:26 +00:00
Waylan Limberg
aebfcdc39c Merge pull request #1026 from waylan/global_vars
Global Template vars refactor
2016-09-28 09:07:12 -04:00
Waylan Limberg
f5b5446b71 Use absolute URLs in nav & media links from error templates.
An error page can be served from any location and therefore it is
impossable to pre-build an error page with correct relative URLs.
With absolute URLs, the error pages will properly link to other
pages in the nav as well as media files (css, js, images, etc) from
the template regardless of the actual URL the file is served from.

However, to continue to support environments where the docs root is a subdir
of the server root, all other pages must continue to use relative URLs.
The `site_url` is used to determine the server root when building
absolute URLs for the error page to ensure those URLs continue to work
in that type of environment.

Relative URLs are also nessecary for those who browse the site on the
local file system (via `file://`). In that case, the error page will be
broken. However, as error pages are not served by a local file system,
this is no more than a minor inconvience. Error pages should always be
tested from a server environment.

Fixes #77.
2016-08-29 10:14:09 -04:00
Waylan Limberg
1444523c0a Update release notes for recent commits. 2016-08-25 21:40:39 -04:00
Waylan Limberg
50e1734490 Deprecate site_favicon config setting and favicon template var
Templates need only include `{{ base_url }}/img/favicon.ico` and
users only need to create a file at `img/favicon.ico` in their
`docs_dir`.

Fixes #725.
2016-08-18 14:24:12 -04:00
Waylan Limberg
2641b6409d Refactor global template variables.
Any template variables which mirrored a config setting have been deprecated
and should be accessed via the coresponding config template variable.

This resolves the rest of #874.
2016-08-15 20:53:21 -04:00