diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModel.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModel.kt index 0c8f5d41..cb835190 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModel.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModel.kt @@ -1,16 +1,7 @@ package nl.avisi.structurizr.site.generatr.site.model import nl.avisi.structurizr.site.generatr.site.GeneratorContext -import nl.avisi.structurizr.site.generatr.site.model.indexing.home -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemComponents -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemContainers -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemContext -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemDecisions -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemHome -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemRelationships -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemSections -import nl.avisi.structurizr.site.generatr.site.model.indexing.workspaceDecisions -import nl.avisi.structurizr.site.generatr.site.model.indexing.workspaceSections +import nl.avisi.structurizr.site.generatr.site.model.indexing.* class SearchViewModel(generatorContext: GeneratorContext) : PageViewModel(generatorContext) { override val pageSubTitle = "Search results" @@ -36,7 +27,19 @@ class SearchViewModel(generatorContext: GeneratorContext) : PageViewModel(genera addAll(softwareSystemSections(it, this@SearchViewModel)) } } - .mapNotNull { it }, + .mapNotNull { it } + ) + addAll( + includedSoftwareSystems + .flatMap { + buildList { + it.containers.forEach { + addAll(softwareSystemContainerSections(it, this@SearchViewModel)) + addAll(softwareSystemContainerDecisions(it, this@SearchViewModel)) + } + } + } + .mapNotNull { it } ) }.mapNotNull { it } diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerDecisions.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerDecisions.kt new file mode 100644 index 00000000..1e4c615c --- /dev/null +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerDecisions.kt @@ -0,0 +1,22 @@ +package nl.avisi.structurizr.site.generatr.site.model.indexing + +import com.structurizr.model.Container +import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory +import nl.avisi.structurizr.site.generatr.site.model.PageViewModel +import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerDecisionPageViewModel +import nl.avisi.structurizr.site.generatr.site.model.contentText + +fun softwareSystemContainerDecisions(container: Container, viewModel: PageViewModel) = container + .documentation + .decisions + .map { decision -> + Document( + SoftwareSystemContainerDecisionPageViewModel.url( + container, + decision + ).asUrlToDirectory(viewModel.url), + "Container Decision", + "${container.name} | ${decision.title}", + "${decision.title} ${decision.contentText()}".trim() + ) + } diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerSections.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerSections.kt new file mode 100644 index 00000000..ca42f3c1 --- /dev/null +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemContainerSections.kt @@ -0,0 +1,20 @@ +package nl.avisi.structurizr.site.generatr.site.model.indexing + +import com.structurizr.model.Container +import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory +import nl.avisi.structurizr.site.generatr.site.model.* + +fun softwareSystemContainerSections(container: Container, viewModel: PageViewModel) = container + .documentation + .sections + .map { section -> + Document( + SoftwareSystemContainerSectionPageViewModel.url( + container, + section + ).asUrlToDirectory(viewModel.url), + "Container Documentation", + "${container.name} | ${section.contentTitle()}", + "${section.contentTitle()} ${section.contentText()}".trim() + ) + } diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemDecisions.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemDecisions.kt index 9fd2dd24..c2774e0e 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemDecisions.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemDecisions.kt @@ -3,20 +3,18 @@ package nl.avisi.structurizr.site.generatr.site.model.indexing import com.structurizr.model.SoftwareSystem import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory import nl.avisi.structurizr.site.generatr.site.model.PageViewModel -import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemPageViewModel +import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemDecisionPageViewModel import nl.avisi.structurizr.site.generatr.site.model.contentText fun softwareSystemDecisions(softwareSystem: SoftwareSystem, viewModel: PageViewModel) = softwareSystem.documentation .decisions .map { decision -> Document( - "${ - SoftwareSystemPageViewModel.url( - softwareSystem, - SoftwareSystemPageViewModel.Tab.HOME - ) - }/decisions/${decision.id}".asUrlToDirectory(viewModel.url), - "Decision", + SoftwareSystemDecisionPageViewModel.url( + softwareSystem, + decision + ).asUrlToDirectory(viewModel.url), + "Software System Decision", "${softwareSystem.name} | ${decision.title}", "${decision.title} ${decision.contentText()}".trim() ) diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemSections.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemSections.kt index 93fb1213..d7a03bcb 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemSections.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/SoftwareSystemSections.kt @@ -2,23 +2,18 @@ package nl.avisi.structurizr.site.generatr.site.model.indexing import com.structurizr.model.SoftwareSystem import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory -import nl.avisi.structurizr.site.generatr.site.model.PageViewModel -import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemPageViewModel -import nl.avisi.structurizr.site.generatr.site.model.contentText -import nl.avisi.structurizr.site.generatr.site.model.contentTitle +import nl.avisi.structurizr.site.generatr.site.model.* fun softwareSystemSections(softwareSystem: SoftwareSystem, viewModel: PageViewModel) = softwareSystem.documentation .sections .drop(1) // Drop software system home .map { section -> Document( - "${ - SoftwareSystemPageViewModel.url( - softwareSystem, - SoftwareSystemPageViewModel.Tab.HOME - ) - }/sections/${section.order}".asUrlToDirectory(viewModel.url), - "Documentation", + SoftwareSystemSectionPageViewModel.url( + softwareSystem, + section + ).asUrlToDirectory(viewModel.url), + "Software System Documentation", "${softwareSystem.name} | ${section.contentTitle()}", "${section.contentTitle()} ${section.contentText()}".trim() ) diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceDecisions.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceDecisions.kt index 63624475..d6a8479c 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceDecisions.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceDecisions.kt @@ -3,12 +3,14 @@ package nl.avisi.structurizr.site.generatr.site.model.indexing import com.structurizr.documentation.Documentation import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory import nl.avisi.structurizr.site.generatr.site.model.PageViewModel +import nl.avisi.structurizr.site.generatr.site.model.WorkspaceDecisionPageViewModel import nl.avisi.structurizr.site.generatr.site.model.contentText fun workspaceDecisions(documentation: Documentation, viewModel: PageViewModel) = documentation.decisions .map { decision -> Document( - "/decisions/${decision.id}".asUrlToDirectory(viewModel.url), + WorkspaceDecisionPageViewModel.url(decision) + .asUrlToDirectory(viewModel.url), "Workspace Decision", decision.title, "${decision.title} ${decision.contentText()}".trim() diff --git a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceSections.kt b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceSections.kt index 5d35709e..8c348459 100644 --- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceSections.kt +++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/indexing/WorkspaceSections.kt @@ -4,6 +4,7 @@ import com.structurizr.documentation.Documentation import nl.avisi.structurizr.site.generatr.normalize import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory import nl.avisi.structurizr.site.generatr.site.model.PageViewModel +import nl.avisi.structurizr.site.generatr.site.model.WorkspaceDocumentationSectionPageViewModel import nl.avisi.structurizr.site.generatr.site.model.contentText import nl.avisi.structurizr.site.generatr.site.model.contentTitle @@ -11,7 +12,8 @@ fun workspaceSections(documentation: Documentation, viewModel: PageViewModel) = .drop(1) // Drop home .map { section -> Document( - "/${section.contentTitle().normalize()}".asUrlToDirectory(viewModel.url), + WorkspaceDocumentationSectionPageViewModel.url(section) + .asUrlToDirectory(viewModel.url), "Workspace Documentation", section.contentTitle(), "${section.contentTitle()} ${section.contentText()}".trim() diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/IndexingTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/IndexingTest.kt index 107a7478..4f44b52f 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/IndexingTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/IndexingTest.kt @@ -8,17 +8,7 @@ import assertk.assertions.isEqualTo import assertk.assertions.isNull import com.structurizr.documentation.Format import com.structurizr.documentation.Section -import nl.avisi.structurizr.site.generatr.site.model.indexing.Document -import nl.avisi.structurizr.site.generatr.site.model.indexing.home -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemComponents -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemContainers -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemContext -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemDecisions -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemHome -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemRelationships -import nl.avisi.structurizr.site.generatr.site.model.indexing.softwareSystemSections -import nl.avisi.structurizr.site.generatr.site.model.indexing.workspaceDecisions -import nl.avisi.structurizr.site.generatr.site.model.indexing.workspaceSections +import nl.avisi.structurizr.site.generatr.site.model.indexing.* import kotlin.test.Test class IndexingTest : ViewModelTest() { @@ -265,13 +255,13 @@ class IndexingTest : ViewModelTest() { assertThat(documents).containsAtLeast( Document( "../software-system-1/decisions/1/", - "Decision", + "Software System Decision", "Software System 1 | Decision 1", "Decision 1 Decision 1 content" ), Document( "../software-system-1/decisions/2/", - "Decision", + "Software System Decision", "Software System 1 | Decision 2", "Decision 2 Decision 2 content" ) @@ -279,7 +269,7 @@ class IndexingTest : ViewModelTest() { } @Test - fun `no software system documentation`() { + fun `no software system sections`() { workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all") val documents = softwareSystemSections(workspace.model.softwareSystems.single(), this.pageViewModel()) @@ -287,7 +277,7 @@ class IndexingTest : ViewModelTest() { } @Test - fun `only software system documentation for software system home`() { + fun `only software system section for software system home`() { workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all").apply { documentation.addSection(Section(Format.Markdown, "# Introduction\nSome info")) } @@ -307,17 +297,86 @@ class IndexingTest : ViewModelTest() { assertThat(documents).containsAtLeast( Document( - "../software-system-1/sections/2/", - "Documentation", + "../software-system-1/sections/usage/", + "Software System Documentation", "Software System 1 | Usage", "Usage That's how it works" ), Document( - "../software-system-1/sections/3/", - "Documentation", + "../software-system-1/sections/history/", + "Software System Documentation", "Software System 1 | History", "History That's how we got here" ) ) } + + @Test + fun `no container sections`() { + val softwareSystem = workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all") + softwareSystem.addContainer("Container 1", "a container") + val documents = softwareSystemContainerSections(softwareSystem.containers.single(), this.pageViewModel()) + + assertThat(documents).isEmpty() + } + + @Test + fun `no container decisions`() { + val softwareSystem = workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all") + softwareSystem.addContainer("Container 1", "a container") + val documents = softwareSystemContainerDecisions(softwareSystem.containers.single(), this.pageViewModel()) + + assertThat(documents).isEmpty() + } + + @Test + fun `indexes container decisions`() { + val softwareSystem = workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all") + val container = softwareSystem.addContainer("Container 1", "a container").apply { + documentation.addDecision(createDecision("1")) + documentation.addDecision(createDecision("2")) + } + val documents = softwareSystemContainerDecisions(container, this.pageViewModel()) + + assertThat(documents).containsAtLeast( + Document( + "../software-system-1/decisions/container-1/1/", + "Container Decision", + "Container 1 | Decision 1", + "Decision 1 Decision 1 content" + ), + Document( + "../software-system-1/decisions/container-1/2/", + "Container Decision", + "Container 1 | Decision 2", + "Decision 2 Decision 2 content" + ) + ) + } + + @Test + fun `indexes container sections`() { + val softwareSystem = workspace.model.addSoftwareSystem("Software System 1", "One system to rule them all") + val container = softwareSystem.addContainer("Container 1", "a container").apply { + documentation.addSection(Section(Format.Markdown, "# Introduction\nSome info")) + documentation.addSection(Section(Format.Markdown, "# Usage\nThat's how it works")) + documentation.addSection(Section(Format.Markdown, "# History\nThat's how we got here")) + } + val documents = softwareSystemContainerSections(container, this.pageViewModel()) + + assertThat(documents).containsAtLeast( + Document( + "../software-system-1/sections/container-1/usage/", + "Container Documentation", + "Container 1 | Usage", + "Usage That's how it works" + ), + Document( + "../software-system-1/sections/container-1/history/", + "Container Documentation", + "Container 1 | History", + "History That's how we got here" + ) + ) + } } diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModelTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModelTest.kt index 6ebd8b55..43a2021a 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModelTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SearchViewModelTest.kt @@ -81,6 +81,8 @@ class SearchViewModelTest : ViewModelTest() { documentation.addSection(Section(Format.Markdown, "# Introduction\nSome info")) addContainer("Container 1", "a container").apply { addComponent("Component 1", "a component") + documentation.addDecision(createDecision("1")) + documentation.addSection(Section(Format.Markdown, "# Component Usage\nThat's how it works")) } documentation.addDecision(createDecision("1")) documentation.addSection(Section(Format.Markdown, "# Usage\nThat's how it works")) @@ -94,8 +96,10 @@ class SearchViewModelTest : ViewModelTest() { "Context views", "Container views", "Component views", - "Decision", - "Documentation" + "Software System Decision", + "Software System Documentation", + "Container Documentation", + "Container Decision" ) }