Skip to content

Commit c85e91f

Browse files
bihbartvandenende-wmduncanmmacleodFokko
authored
1.1.1: Remove overly restrictive directory structure (#140)
* feat: add support for monorepos with symlink folders * edit_uri: fix edit URL for nested site_name fixes #127 and adds regression test for nested site_name in included project * Avoid replacing dots for underscores Resolves #123 * feat: removed restrictions on using directories outside root * chore: fmt * chore: bump dependencies * docs: mention fixtures in readme * fix: bump to 1.1.1 * docs: mention #129 in changelog * docs: mention #108 * docs: add #122 * docs: add #128 --------- Co-authored-by: Bart van den Ende <bart.van.den.ende@wbd.com> Co-authored-by: Duncan Macleod <duncan.macleod@ligo.org> Co-authored-by: Fokko Driesprong <fokko@apache.org>
1 parent 02fbd09 commit c85e91f

18 files changed

Lines changed: 306 additions & 218 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ $ pip install mkdocs-monorepo-plugin
3131

3232
Take a look in [our sample project](./sample-docs) for an example implementation, or see [what it looks like after running `mkdocs build`](https://backstage.github.io/mkdocs-monorepo-plugin/monorepo-example/).
3333

34+
For further examples, take a look at our [test suite](__tests__/integration/fixtures) which covers dozens of good and bad examples of using Mkdocs with the `monorepo` plugin.
35+
3436
In general, this plugin introduces the `!include` syntax in your Mkdocs navigation structure and then merges them together.
3537

3638
```yaml
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API Documentation
2+
3+
Some sub documentation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Other Documentation
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
site_name: "test/api"
2+
site_description: "This is an api."
3+
repo_url: https://github.com/backstage/mkdocs-monorepo-plugin
4+
edit_uri: edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/
5+
6+
plugins:
7+
- monorepo
8+
9+
nav:
10+
- Home: index.md
11+
- Other: other/other.md
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Top Level Project Documentation
2+
3+
Some higher level info about the project
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Other Documentation
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
site_name: "Example"
2+
site_description: "Description Here"
3+
repo_url: https://github.com/backstage/mkdocs-monorepo-plugin
4+
edit_uri: edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/
5+
6+
plugins:
7+
- monorepo
8+
9+
nav:
10+
- Home: "index.md"
11+
- Other: "other.md"
12+
- API: "!include api/mkdocs.yml"

__tests__/integration/fixtures/error-include-path-is-parent/docs/index.md renamed to __tests__/integration/fixtures/ok-include-path-outside-root/docs/index.md

File renamed without changes.

__tests__/integration/fixtures/error-include-path-is-parent/mkdocs.yml renamed to __tests__/integration/fixtures/ok-include-path-outside-root/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ plugins:
88

99
nav:
1010
- Home: index.md
11-
- Section: '!include ../mkdocs.yml'
11+
- Section: '!include ../ok/project-a/mkdocs.yml'

__tests__/integration/test.bats

100644100755
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,15 @@ teardown() {
198198
[[ "$output" == *"This contains a sentence which only exists in the ok-include-wildcard/project-b fixture."* ]]
199199
}
200200

201-
@test "fails if !include path is above current folder" {
202-
cd ${fixturesDir}/error-include-path-is-parent
203-
assertFailedMkdocs build
204-
[[ "$output" == *"[mkdocs-monorepo] The mkdocs file "*"/__tests__/integration/fixtures/mkdocs.yml is outside of the current directory. Please move the file and try again."* ]]
201+
@test "builds a mkdocs site if !include path is outside root" {
202+
cd ${fixturesDir}/ok-include-path-outside-root
203+
assertSuccessMkdocs build
204+
205+
assertFileExists site/index.html
206+
[[ "$output" == *"Lorem markdownum aequora Famemque, a ramos regna Ulixem verba, posito qui
207+
nubilus membra."* ]]
208+
assertFileExists site/test/index.html
209+
[[ "$output" == *"This contains a sentence which only exists in the ok/project-a fixture."* ]]
205210
}
206211

207212
@test "fails if !include path contains !include" {
@@ -268,6 +273,15 @@ teardown() {
268273
assertFileContains './site/test/other/other/index.html' 'href="https://github.com/backstage/mkdocs-monorepo-plugin/edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri/api/docs/other/other.md"'
269274
}
270275

276+
@test "sets edit url for nested included path pages" {
277+
cd ${fixturesDir}/ok-include-path-edit-uri-nested
278+
assertSuccessMkdocs build
279+
280+
assertFileContains './site/index.html' 'href="https://github.com/backstage/mkdocs-monorepo-plugin/edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/index.md"'
281+
assertFileContains './site/test/api/index.html' 'href="https://github.com/backstage/mkdocs-monorepo-plugin/edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/index.md"'
282+
assertFileContains './site/test/api/other/other/index.html' 'href="https://github.com/backstage/mkdocs-monorepo-plugin/edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/other/other.md"'
283+
}
284+
271285
@test "sets edit url for included wildcard pages" {
272286
cd ${fixturesDir}/ok-include-wildcard-edit-uri
273287
assertSuccessMkdocs build

0 commit comments

Comments
 (0)