Merge pull request #1 from dariocurr/no_docs_dir

No docs dir
This commit is contained in:
Dario Curreri 2022-07-29 16:24:03 +02:00 committed by GitHub
commit a885ceaa78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 17 deletions

View File

@ -1,7 +0,0 @@
site_name: 'test'
site_description: 'This is a subdomain site.'
plugins:
- monorepo
docs_dir: docs

View File

@ -0,0 +1,3 @@
# Hello world!
This contains a sentence which only exists in the ok/project-a fixture.

View File

@ -0,0 +1,5 @@
site_name: "test"
site_description: "This is a subdomain site."
plugins:
- monorepo

View File

@ -103,6 +103,13 @@ teardown() {
[[ "$output" == *"This contains a sentence which only exists in the ok/project-a fixture."* ]]
}
@test "builds a mkdocs site with no nav and no docs_dir key" {
cd ${fixturesDir}/ok-no-nav-no-dir
assertSuccessMkdocs build
assertFileExists site/test/index.html
[[ "$output" == *"This contains a sentence which only exists in the ok/project-a fixture."* ]]
}
@test "builds a mkdocs site with yaml extension" {
cd ${fixturesDir}/ok-yaml-not-yml
assertSuccessMkdocs build
@ -227,12 +234,6 @@ teardown() {
[[ "$output" == *"[mkdocs-monorepo] The /"*"/__tests__/integration/fixtures/error-include-path-no-docs-folder/project-a/docs path is not valid. Please update your 'nav' with a valid path."* ]]
}
@test "fails if !include path docs_dir does not contain any files" {
cd ${fixturesDir}/error-no-nav-no-docs
assertFailedMkdocs build
[[ "$output" == *"[mkdocs-monorepo] The file path /"*"/__tests__/integration/fixtures/error-no-nav-no-docs/project-a/mkdocs.yml does not contain a valid 'nav' key in the YAML file. Please include it to indicate how your documentation should be presented in the navigation, or include a 'docs_dir' to indicate that automatic nav generation should be used."* ]]
}
@test "fails if absolute links aren't supported" {
cd ${fixturesDir}/include-path-absolute-url
assertSuccessMkdocs build

View File

@ -185,8 +185,9 @@ class IncludeNavLoader:
# This will check if there is a `docs_dir` property on the `mkdocs.yml` file of
# the sub folder and scaffold the `nav` property from it
if self.navYaml and 'nav' not in self.navYaml and "docs_dir" in self.navYaml:
docsDirPath = os.path.join(os.path.dirname(self.absNavPath), self.navYaml["docs_dir"])
if self.navYaml and 'nav' not in self.navYaml:
docsDir = self.navYaml.get("docs_dir", "docs")
docsDirPath = os.path.join(os.path.dirname(self.absNavPath), docsDir)
def navFromDir(path):
directory = {}
@ -242,8 +243,9 @@ class IncludeNavLoader:
if self.navYaml and 'nav' not in self.navYaml:
log.critical(
"[mkdocs-monorepo] The file path {} ".format(self.absNavPath) +
"does not contain a valid 'nav' key in the YAML file. " +
"Please include it to indicate how your documentation should be presented in the navigation, " +
"does not contain a valid 'nav' key in the YAML file " +
"and the docs folder is not the default one, i.e. `docs`. " +
"Please include the `nav` key to indicate how your documentation should be presented in the navigation, " +
"or include a 'docs_dir' to indicate that automatic nav generation should be used."
)
raise SystemExit(1)