From 6b6060a7b7df19e7d86f44f4b0b15f24a3fc741e Mon Sep 17 00:00:00 2001 From: Seungyeop Han Date: Tue, 21 Feb 2023 21:08:58 +0000 Subject: [PATCH] Allow cross-referencing in navs --- .../fixtures/ok-cross-reference/docs/cross.md | 3 ++ .../fixtures/ok-cross-reference/docs/index.md | 53 +++++++++++++++++++ .../fixtures/ok-cross-reference/mkdocs.yml | 13 +++++ .../project-a/docs/README.md | 3 ++ .../ok-cross-reference/project-a/mkdocs.yml | 9 ++++ __tests__/integration/test.bats | 6 +++ docs/CHANGELOG.md | 4 ++ mkdocs_monorepo_plugin/parser.py | 4 +- setup.py | 4 +- 9 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 __tests__/integration/fixtures/ok-cross-reference/docs/cross.md create mode 100644 __tests__/integration/fixtures/ok-cross-reference/docs/index.md create mode 100644 __tests__/integration/fixtures/ok-cross-reference/mkdocs.yml create mode 100644 __tests__/integration/fixtures/ok-cross-reference/project-a/docs/README.md create mode 100644 __tests__/integration/fixtures/ok-cross-reference/project-a/mkdocs.yml diff --git a/__tests__/integration/fixtures/ok-cross-reference/docs/cross.md b/__tests__/integration/fixtures/ok-cross-reference/docs/cross.md new file mode 100644 index 0000000..0291d3a --- /dev/null +++ b/__tests__/integration/fixtures/ok-cross-reference/docs/cross.md @@ -0,0 +1,3 @@ +# Cross-referenced + +This is included in project-a's nav diff --git a/__tests__/integration/fixtures/ok-cross-reference/docs/index.md b/__tests__/integration/fixtures/ok-cross-reference/docs/index.md new file mode 100644 index 0000000..8ead955 --- /dev/null +++ b/__tests__/integration/fixtures/ok-cross-reference/docs/index.md @@ -0,0 +1,53 @@ +# Neptunia vapor + +## Has mente et + +Lorem markdownum aequora Famemque, a ramos regna Ulixem verba, posito qui +nubilus membra. Pendet dixit canisve, hanc quoque animosa **veni**, inducere. +Fer quem, mihi vallem; reposcunt aequoreae Haec, inposita. Eras dicere sic! Ore +ad at nec pius rivi pectora Pandione amari pietas Ulixem. + +> Argenteus sinit. Corpore non Booten Uranie, in hac has dixi herbas. *Oculos +> omnes Dixerat* suae coloribus et antris spernitque silva, dixit. + +Mihi [quamvis](http://caput-latebris.com/), ardua venit nam, de mox in et inquit +incisa relevare reseminet Cycnus forma sororis. In mater artus utque iustis me +vestrae magno datque, quaque multumque oscula iubemur. + +## Aditumque ubi + +Brevibus cervice inmunibus sunt peragit, [sua tanto +insuper](http://ampycuslyncides.org/), arva ubi: torto mixta. Sanguis +conscendunt sumit, utilis illo nec quaecumque ad urbis inpositaque. Alto sic +esse resumere albet, pharetras sola, erat, [non longo +paviunt](http://verba.org/) dives aurem. Nomina genus nulli insignia, carpere +dare quo vident, *nox flemus sed* Telamon auras, erant illuc, tantum. Regia +[duroque opto](http://www.flectathiberi.io/estredeunt), segetes paterna de +crimen! + + var edutainment_php = plain_ring_scan(adfUgcImap * delPanel); + var click_meta_dv = 3 + + systemScrollingDocument.snippetCdAnimated.memoryInstallHost(service( + bezel_trojan_plagiarism, 1, base_resources), intelligence, + umlWiSkin.software_olap.on(quadHocData)); + var bare = jumper_server_solid - rupE + 3; + var timeRegistryStandby = disk_ppc_menu + gigahertzCifsRss; + if (im(correction_desktop, disk_integer_soft(serviceLogic, data_zone, + daw_ssid_web)) > graphicsExpansionBug + active) { + apiSpam = storageVisual + 3; + } + +Mors cum cum proturbat, gente nasci Semiramis sonum, toto est eris facto dapibus +propulit; a! Rogantis ira canat, [in nec +sanguine](http://acceptiordefensus.io/accepto) probro inmunesque molliter +sustineat quem quamquam parentis non. Per **quod nec** rapit ipsa nec, +territaque fallacis fluviis progenies aratro. Colla puer regesta si Haec +silentia omen Paeonia, harenis puer Marmaridae pectora ingens miratur Thisbes +veri. Plaga profugi, iram, praestans, pro hanc vehit, vites. + +Illa per acerris vivit difficile pulveris, faciebat pontus populabile utque? In +flagrant umbrae marito, coniunx parari, **quoque sanguine Nisi**, ego +[saxo](http://cervice-fessusque.com/), fovet, ait unda contigit. Gaudet in, +herba quibus? Ore ne ambo mecumque pectoraque alta: viri illi in puer corpore +expersque pharetra solutum proximitas. Gorgonis adempto, in montes terga quae +nec remoratur nives perque insidias exsiluit tribuitque mille. diff --git a/__tests__/integration/fixtures/ok-cross-reference/mkdocs.yml b/__tests__/integration/fixtures/ok-cross-reference/mkdocs.yml new file mode 100644 index 0000000..17556fc --- /dev/null +++ b/__tests__/integration/fixtures/ok-cross-reference/mkdocs.yml @@ -0,0 +1,13 @@ +site_name: "Example" +site_description: "Description Here" + +docs_dir: ./docs + +plugins: + - monorepo + +nav: + - Home: "index.md" + - Subnav: + - index.md + - Hello: "!include project-a/mkdocs.yml" diff --git a/__tests__/integration/fixtures/ok-cross-reference/project-a/docs/README.md b/__tests__/integration/fixtures/ok-cross-reference/project-a/docs/README.md new file mode 100644 index 0000000..4104f83 --- /dev/null +++ b/__tests__/integration/fixtures/ok-cross-reference/project-a/docs/README.md @@ -0,0 +1,3 @@ +# Hello world! + +This contains a sentence which only exists in the ok/project-a fixture. diff --git a/__tests__/integration/fixtures/ok-cross-reference/project-a/mkdocs.yml b/__tests__/integration/fixtures/ok-cross-reference/project-a/mkdocs.yml new file mode 100644 index 0000000..7ccddbc --- /dev/null +++ b/__tests__/integration/fixtures/ok-cross-reference/project-a/mkdocs.yml @@ -0,0 +1,9 @@ +site_name: 'test' +site_description: 'This is a subdomain site.' + +plugins: + - monorepo + +nav: + - Home: README.md + - ../cross.md diff --git a/__tests__/integration/test.bats b/__tests__/integration/test.bats index c7f133c..34a8708 100644 --- a/__tests__/integration/test.bats +++ b/__tests__/integration/test.bats @@ -313,3 +313,9 @@ teardown() { assertFileNotContains './site/test/other/other/index.html' 'href="https://github.com/backstage/mkdocs-monorepo-plugin/edit/master/__tests__/integration/fixtures/ok-include-wildcard-no-repo-url/projects/api/docs/other/other.md"' } +@test "builds a mkdocs site with cross-referencing from subsite" { + cd ${fixturesDir}/ok-cross-reference + assertSuccessMkdocs build + assertFileContains './site/index.html' 'Cross-referenced' +} + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 608a28f..ba0aa41 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.5 + +- Allow cross sub-docs reference in `nav` + ## 1.0.4 - Resolve a bug that prevented this plugin from working with mkdocs >= v1.4.0 diff --git a/mkdocs_monorepo_plugin/parser.py b/mkdocs_monorepo_plugin/parser.py index 4a80d5d..ccb08fa 100644 --- a/mkdocs_monorepo_plugin/parser.py +++ b/mkdocs_monorepo_plugin/parser.py @@ -296,9 +296,9 @@ def formatNavLink(alias, value): return "{}/{}".format(alias, value) if key is None: - nav[index] = formatNavLink(alias, value) + nav[index] = os.path.normpath(formatNavLink(alias, value)) else: - nav[index][key] = formatNavLink(alias, value) + nav[index][key] = os.path.normpath(formatNavLink(alias, value)) elif type(value) == list: nav[index] = {} diff --git a/setup.py b/setup.py index c37ed5e..939ee2e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setuptools.setup( name='mkdocs-monorepo-plugin', - version='1.0.4', + version='1.0.4.1', description='Plugin for adding monorepository support in Mkdocs.', long_description=""" This introduces support for the !include syntax in mkdocs.yml, allowing you to import additional Mkdocs navigation. @@ -17,7 +17,7 @@ license='Apache-2.0', python_requires='>=3', install_requires=[ - 'mkdocs>=1.0.4', + 'mkdocs>=1.0.5', 'python-slugify>=4.0.1' ], classifiers=[