Commit Graph

2041 Commits

Author SHA1 Message Date
Oleh Prypin
5dc51b7b21 Merge pull request #3451 from mkdocs/genfile
Rework Files to support generated files
2024-01-26 21:01:51 +01:00
Andre_601
7186f4ce9c Remove mention of site_url being required option (#3525) 2023-12-23 13:59:57 +01:00
Oleh Prypin
b3f278ae73 Split out the anchor-collecting processor at an earlier priority (#3520)
If it matches the priority of the 'toc' processor, it's more likely to be correct
2023-12-17 17:01:14 +01:00
Oleh Prypin
15bd2d5ea0 Exclude tests from the wheel distribution (#3522) 2023-12-17 17:00:48 +01:00
Oleh Prypin
ee2a7ab45c Ensure nav is sorted regardless of the order inside Files
This means plugins don't have to carefully find the sort order to put files in.
2023-12-16 00:57:27 +01:00
Oleh Prypin
bf3e76c4c8 Rework Files internal collection as dict instead of list 2023-12-16 00:56:16 +01:00
Oleh Prypin
666d764a3f Add File.generated factory method for files
-it populates `generated_by` automatically as well, based on the currently running plugin event.
2023-12-16 00:56:02 +01:00
Oleh Prypin
680e3f66d4 Allow File content to be based on an in-memory string
Add a new field `content_bytes`/`content_string` to read the content regardless of whether it's backed by the new style or still by `abs_src_path` (which is now not always present)
2023-12-16 00:53:45 +01:00
Oleh Prypin
f22f474ecc Support overriding edit_uri on a File 2023-12-15 23:54:01 +01:00
Oleh Prypin
80ffca5082 Refactor set_edit_url 2023-12-15 23:47:55 +01:00
Oleh Prypin
31fa307860 Add generated_by attribute to File
Co-authored-by: Tim Vink <vinktim@gmail.com>
2023-12-15 23:42:12 +01:00
Oleh Prypin
0b5ef68184 Make fields of File computed on demand
The previous attempt always computed these on the fly https://github.com/mkdocs/mkdocs/pull/3017
but now they will be cached after first access, so the performance penalty is avoided.

The fields can still be overwritten manually.
And one can ask the fields to be recomputed by using the `del` operation.
2023-12-15 23:42:10 +01:00
Oleh Prypin
8833edcc94 Fix some broken links 2023-12-15 21:56:25 +01:00
Oleh Prypin
e48d6e6c53 Merge pull request #3485 from mkdocs/abs
Validation of absolute links relative to docs root
2023-12-15 11:57:31 +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
224676fbae Fix broken links 2023-12-14 21:52:40 +01:00
Oleh Prypin
7245a636cc Also make 'relative_to_docs' work for nav validation 2023-12-11 23:51:56 +01:00
Oleh Prypin
a42ab62311 Validation of absolute links relative to docs root 2023-12-11 23:51:50 +01:00
Oleh Prypin
9e443d2120 For validation, pick up anchors also from raw HTML (#3505) 2023-12-11 23:49:10 +01:00
Oleh Prypin
03cc0fa457 Merge pull request #3511 from mkdocs/contributing
Update CONTRIBUTING.md
2023-12-11 23:43:35 +01:00
Allison Thackston
3e809b6bd6 Add additional 'drafts' level to inclusion (#3476)
Co-authored-by: Oleh Prypin <oleh@pryp.in>
2023-12-11 22:36:36 +01:00
Oleh Prypin
09ff0ab247 Update CONTRIBUTING.md 2023-12-10 16:44:30 +01:00
Oleh Prypin
9af473c71c Let's use pymdownx.snippets for the move 2023-12-10 14:10:01 +01:00
Oleh Prypin
f40f3bfe92 Move CONTRIBUTING.md doc to the root 2023-12-10 10:41:22 +01:00
Oleh Prypin
91837c94e3 Drop the file CONTRIBUTING.md, in preparation for a move 2023-12-10 10:41:22 +01:00
Oleh Prypin
d110f03f48 CI: Bump node-version 2023-12-09 18:25:38 +01:00
Oleh Prypin
1910381516 Merge pull request #3463 from mkdocs/anch
Implement validation of anchors in links to other pages
2023-12-09 18:08:16 +01:00
Oleh Prypin
ebaefd7451 Warn when multiple 'on_page_read_source' handlers are added (#3503) 2023-12-08 21:42:42 +01:00
Oleh Prypin
ccf011db79 Make sitemap.xml.gz slightly more reproducible (#3460)
Use the latest page update time instead of the current time

Now the date of the gzip file will change only once per day, based on the pages' update date. The sitemap.xml itself also changes once per day already.
2023-12-08 21:39:14 +01:00
Oleh Prypin
64cab0d77f Merge pull request #3502 from mkdocs/hatchdoc
Use hatch-mkdocs and hatch-pip-compile for docs deps
2023-12-05 21:48:13 +01:00
Oleh Prypin
2929628a8b Fix wrong @tempdir invocations in tests 2023-12-03 23:25:01 +01:00
Oleh Prypin
df2dffd8a6 New flag serve --open to open the site in a browser (#3500)
After the first build is finished, the default webbrowser will open the home page of the site.
2023-12-03 22:00:13 +01:00
Oleh Prypin
8035d78dad Refactor serve URL handling, pass only the URL to build (#3501)
Co-authored-by: Philipp Temminghoff <philipptemminghoff@googlemail.com>
2023-12-03 21:59:46 +01:00
Oleh Prypin
0d25830a20 Add a CI job checking that the docs site builds 2023-12-03 13:11:33 +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
646987da45 Merge pull request #3465 from mkdocs/secu
Stop executing YAML tags for mkdocs_theme.yml, warn about third-party projects
2023-11-21 21:46:31 +01:00
Oleh Prypin
eaf4e4f4c3 Merge pull request #3464 from mkdocs/rtnav
Fix readthedocs theme expanding all top level ToC entries
2023-11-21 21:10:44 +01:00
Oleh Prypin
47e41a9a0e Still use the fast version of SafeLoader 2023-11-21 21:08:28 +01:00
Oleh Prypin
35fb2c7203 Move code to external mkdocs-get-deps dependency (#3477)
The "get-deps" command will still be provided inside MkDocs like before (and is not deprecated at all) but is now implemented in a separate repository and can be used directly from there as well.

This separation of code was done because obtaining just the "get-deps" part with very few dependencies can be useful: one can run it in a main environment but then install actual MkDocs with dependencies in a virtual environment.
2023-11-21 21:03:41 +01:00
Oleh Prypin
8aafea1742 Fix overzealous validation of !relative tag (#3466)
If a Markdown extension immediately resolves the path inside its initialization (rather than just storing it for later as I was hoping) then it was failing the initial validation run that MkDocs does without populating an actual page yet.
2023-11-14 18:35:30 +01:00
Oleh Prypin
c3c980582f Cache the result of the function get_themes() 2023-11-11 16:50:49 +01:00
Oleh Prypin
9ff9bb10bf Docs: warn about installing third-party plugins 2023-11-11 16:50:48 +01:00
Oleh Prypin
9e67e466f8 Stop allowing arbitrary YAML tags for mkdocs_theme.yml 2023-11-11 16:50:48 +01:00
Oleh Prypin
da35dcad0c Support mkdocs-section-index plugin in readthedocs theme
-Handle the case when something is both a page and a section
2023-11-11 16:18:12 +01:00
Oleh Prypin
575a19a5f4 Fix readthedocs theme expanding all top level ToC entries 2023-11-11 16:17:36 +01:00
Oleh Prypin
04cca3bff7 Implement validation of anchors in links to other pages
Example message:

    WARNING -  Doc file 'dev-guide/themes.md' contains a link '../user-guide/configuration.md#google_analytics', but the doc 'user-guide/configuration.md' does not contain an anchor '#google>

It is not enabled by default. To enable, use config `validation: {anchors: warn}`

The implementation only detects Markdown anchors, not raw HTML anchors. As such it may have false positives.

```markdown
<a id="undetectable-anchor"></a>

## Detectable anchor
```

There are plans to improve that in the future.

But that's just about user-authored HTML.
As for HTML that Markdown extensions insert: it will also work correctly if they insert the HTML as etree elements and will never work if they insert it via `htmlStash`. Basically the same rules as for what `toc_tokens` is able to detect.
2023-11-11 16:07:25 +01:00
Oleh Prypin
3f7c5ca129 Update docs about logging in plugins 2023-11-11 16:07:25 +01:00
Oleh Prypin
4ce945e72c Set logging levels on the logger rather than just the stream
Otherwise currently `log.getEffectiveLevel()` always reports `1` and doesn't allow optimizing away debug logging statemets.
2023-11-11 15:55:03 +01:00
Oleh Prypin
7c3c3981b8 Docs: fix or drop broken anchor links 2023-11-11 14:28:14 +01:00
Oleh Prypin
96bfc70210 Make File hashable, without __eq__ 2023-11-11 14:28:04 +01:00