Skip to content

Support docs from the root directory.#3450

Draft
athackst wants to merge 8 commits intomkdocs:masterfrom
athackst:feat/root-dir-docs
Draft

Support docs from the root directory.#3450
athackst wants to merge 8 commits intomkdocs:masterfrom
athackst:feat/root-dir-docs

Conversation

@athackst
Copy link
Copy Markdown
Contributor

@athackst athackst commented Oct 29, 2023

Per discussion #3062 this change would allow users to build a mkdocs site from the root directory.

This change removes the validation checks for the site directory to not be within the docs directory.
If the site folder is within the docs directory, it will mark them as 'EXCLUDED'

Tested:

  • added unit test

@athackst
Copy link
Copy Markdown
Contributor Author

athackst commented Oct 29, 2023

It might be worth considering an "ignore" option for InclusionLevel which would additionally not copy to the server, although I think the '--clean' option provides most of the benefit already.

@athackst athackst force-pushed the feat/root-dir-docs branch 2 times, most recently from fb5cd7d to 42ff3a1 Compare October 30, 2023 21:53
@oprypin

This comment was marked as abuse.

@athackst
Copy link
Copy Markdown
Contributor Author

athackst commented Nov 8, 2023

To be clear, it's still usable as is. A normal user would not even notice the extra site folder since nothing links to it. It just copies more than it needs to into the temp directory that serves the site.

It performs as expected on a normal build.

@athackst athackst force-pushed the feat/root-dir-docs branch 3 times, most recently from 0389e27 to 68ad2a3 Compare December 11, 2023 01:03
@athackst
Copy link
Copy Markdown
Contributor Author

@oprypin I updated this one after rebasing on top of #3476

The site directory is now appropriately marked as excluded both in build and serve.

@squidfunk
Copy link
Copy Markdown
Contributor

Note that advertising that site_dir can be contained within docs_dir, albeit it might be supported, could break a lot of plugins that do not source their files from the Files collection, but use something like glob or other ways of enumerating files in the docs_dir. One might argue that those approaches are not idiomatic, but I've seen them more than often (and am guilty as well), so this change has quite some potential for frustration.

@athackst
Copy link
Copy Markdown
Contributor Author

I wouldn't advocate for changing the default from the 'docs' directory. I think there are legitimate use cases for wanting to call mkdocs from root though. It's a feature that's been requested a fair amount through mkdocs history.

@oprypin

This comment was marked as abuse.

@oprypin

This comment was marked as abuse.

@MatthewSteen
Copy link
Copy Markdown

This feature would be useful for documentation-only sites and personal sites deployed with pages.

This can be done with https://github.com/jupyter-book/jupyter-book, which might be a good resource. Here's an example...

Note, another related feature (if not already implemented) would be to allow the index.md to be in the root dir (or readme.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants