diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/index.md b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/index.md new file mode 100644 index 0000000..711b5da --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/index.md @@ -0,0 +1,3 @@ +# API Documentation + +Some sub documentation \ No newline at end of file diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/other/other.md b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/other/other.md new file mode 100644 index 0000000..8e2a183 --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/other/other.md @@ -0,0 +1 @@ +# Other Documentation diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/mkdocs.yml b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/mkdocs.yml new file mode 100644 index 0000000..9e711e0 --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/mkdocs.yml @@ -0,0 +1,11 @@ +site_name: "test/api" +site_description: "This is an api." +repo_url: https://github.com/backstage/mkdocs-monorepo-plugin +edit_uri: edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/api/docs/ + +plugins: + - monorepo + +nav: + - Home: index.md + - Other: other/other.md diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/index.md b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/index.md new file mode 100644 index 0000000..8296e87 --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/index.md @@ -0,0 +1,3 @@ +# Top Level Project Documentation + +Some higher level info about the project \ No newline at end of file diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/other.md b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/other.md new file mode 100644 index 0000000..8e2a183 --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/other.md @@ -0,0 +1 @@ +# Other Documentation diff --git a/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/mkdocs.yml b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/mkdocs.yml new file mode 100644 index 0000000..a644ab7 --- /dev/null +++ b/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/mkdocs.yml @@ -0,0 +1,12 @@ +site_name: "Example" +site_description: "Description Here" +repo_url: https://github.com/backstage/mkdocs-monorepo-plugin +edit_uri: edit/master/__tests__/integration/fixtures/ok-include-path-edit-uri-nested/docs/ + +plugins: + - monorepo + +nav: + - Home: "index.md" + - Other: "other.md" + - API: "!include api/mkdocs.yml" diff --git a/__tests__/integration/test.bats b/__tests__/integration/test.bats index c7f133c..bebd416 100644 --- a/__tests__/integration/test.bats +++ b/__tests__/integration/test.bats @@ -268,6 +268,15 @@ teardown() { 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"' } +@test "sets edit url for nested included path pages" { + cd ${fixturesDir}/ok-include-path-edit-uri-nested + assertSuccessMkdocs build + + 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"' + 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"' + 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"' +} + @test "sets edit url for included wildcard pages" { cd ${fixturesDir}/ok-include-wildcard-edit-uri assertSuccessMkdocs build diff --git a/mkdocs_monorepo_plugin/edit_uri.py b/mkdocs_monorepo_plugin/edit_uri.py index 4b0bbe5..a6b84d7 100644 --- a/mkdocs_monorepo_plugin/edit_uri.py +++ b/mkdocs_monorepo_plugin/edit_uri.py @@ -43,7 +43,7 @@ def __get_page_docs_dir(self): return path.relpath(abs_page_config_file_dir, abs_root_config_file_dir) def __get_page_src_path(self): - alias = self.page.url.split('/')[0] + alias = self.__get_page_dir_alias() path = self.page.file.src_path return path.replace('{}/'.format(alias), '')