-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from jp7677/container-sections
Add support for documentation sections on containers
- Loading branch information
Showing
26 changed files
with
342 additions
and
119 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
docs/example/internet-banking-system/api-application/docs/0001-inner-workings.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Inner workings | ||
|
||
This is how this thing works. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
.../kotlin/nl/avisi/structurizr/site/generatr/site/model/ContainerDecisionsTableViewModel.kt
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/DecisionTabViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,5 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.hasDecisions | ||
|
||
data class DecisionTabViewModel(val pageViewModel: SoftwareSystemPageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url, true) | ||
} | ||
|
||
fun SoftwareSystemPageViewModel.createDecisionsTabViewModel(softwareSystem: SoftwareSystem, tab: SoftwareSystemPageViewModel.Tab): List<DecisionTabViewModel> { | ||
val tabs = buildList<DecisionTabViewModel> { | ||
if (softwareSystem.hasDecisions()) { | ||
add(DecisionTabViewModel( | ||
this@createDecisionsTabViewModel, | ||
"System", | ||
SoftwareSystemPageViewModel.url(softwareSystem, tab) | ||
)) | ||
} | ||
softwareSystem | ||
.containers | ||
.filter { it.hasDecisions() } | ||
.map { | ||
DecisionTabViewModel( | ||
this@createDecisionsTabViewModel, | ||
it.name, | ||
SoftwareSystemContainerDecisionsPageViewModel.url(it) | ||
) | ||
} | ||
.forEach { add(it) } | ||
} | ||
return tabs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SectionTabViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
data class SectionTabViewModel(val pageViewModel: SoftwareSystemPageViewModel, val title: String, val url: String) { | ||
val link = LinkViewModel(pageViewModel, title, url, true) | ||
} |
35 changes: 32 additions & 3 deletions
35
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/SectionsTableViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.documentation.Section | ||
import com.structurizr.model.SoftwareSystem | ||
import nl.avisi.structurizr.site.generatr.hasDocumentationSections | ||
import nl.avisi.structurizr.site.generatr.hasSections | ||
|
||
fun PageViewModel.createSectionsTableViewModel(sections: Collection<Section>, hrefFactory: (Section) -> String) = | ||
fun PageViewModel.createSectionsTableViewModel(sections: Collection<Section>, dropFirst: Boolean = true, hrefFactory: (Section) -> String) = | ||
TableViewModel.create { | ||
headerRow(headerCell("#"), headerCell("Title")) | ||
sections | ||
.sortedBy { it.order } | ||
.drop(1) | ||
.associateWith { it.order - 1 } | ||
.drop(if (dropFirst) 1 else 0) | ||
.associateWith { if (dropFirst) it.order - 1 else it.order } | ||
.forEach { (section, index) -> | ||
bodyRow( | ||
cellWithIndex(index.toString()), | ||
cellWithLink(this@createSectionsTableViewModel, section.contentTitle(), hrefFactory(section)) | ||
) | ||
} | ||
} | ||
|
||
fun SoftwareSystemPageViewModel.createSectionsTabViewModel( | ||
softwareSystem: SoftwareSystem, | ||
tab: SoftwareSystemPageViewModel.Tab | ||
) = buildList { | ||
if (softwareSystem.hasDocumentationSections()) { | ||
add( | ||
SectionTabViewModel( | ||
this@createSectionsTabViewModel, | ||
"System", | ||
SoftwareSystemPageViewModel.url(softwareSystem, tab) | ||
) | ||
) | ||
} | ||
softwareSystem | ||
.containers | ||
.filter { it.hasSections() } | ||
.map { | ||
SectionTabViewModel( | ||
this@createSectionsTabViewModel, | ||
it.name, | ||
SoftwareSystemContainerSectionsPageViewModel.url(it) | ||
) | ||
} | ||
.forEach { add(it) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...avisi/structurizr/site/generatr/site/model/SoftwareSystemContainerSectionPageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.documentation.Section | ||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerSectionPageViewModel( | ||
generatorContext: GeneratorContext, | ||
container: Container, | ||
section: Section | ||
) : SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.SECTIONS) { | ||
override val url = url(container, section) | ||
|
||
val content = markdownToHtml(this, section.content, generatorContext.svgFactory) | ||
|
||
companion object { | ||
fun url(container: Container, section: Section) = | ||
"${url(container.softwareSystem, Tab.SECTIONS)}/${container.name.normalize()}/${section.order}" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...visi/structurizr/site/generatr/site/model/SoftwareSystemContainerSectionsPageViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import com.structurizr.model.Container | ||
import nl.avisi.structurizr.site.generatr.hasSections | ||
import nl.avisi.structurizr.site.generatr.normalize | ||
import nl.avisi.structurizr.site.generatr.site.GeneratorContext | ||
|
||
class SoftwareSystemContainerSectionsPageViewModel(generatorContext: GeneratorContext, container: Container) : | ||
SoftwareSystemPageViewModel(generatorContext, container.softwareSystem, Tab.SECTIONS) { | ||
override val url = url(container) | ||
val sectionsTable = createSectionsTableViewModel(container.documentation.sections, dropFirst = false) { | ||
"$url/${it.order}" | ||
} | ||
|
||
val visible = container.hasSections() | ||
val sectionsTabs = createSectionsTabViewModel(container.softwareSystem, Tab.SECTIONS) | ||
|
||
companion object { | ||
fun url(container: Container) = "${url(container.softwareSystem, Tab.SECTIONS)}/${container.name.normalize()}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...otlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerSectionPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerSectionPageViewModel | ||
|
||
fun HTML.softwareSystemContainerSectionPage(viewModel: SoftwareSystemContainerSectionPageViewModel) { | ||
softwareSystemPage(viewModel) { | ||
rawHtml(viewModel.content) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...tlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemContainerSectionsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package nl.avisi.structurizr.site.generatr.site.views | ||
|
||
import kotlinx.html.HTML | ||
import kotlinx.html.div | ||
import kotlinx.html.li | ||
import kotlinx.html.ul | ||
import nl.avisi.structurizr.site.generatr.site.model.SoftwareSystemContainerSectionsPageViewModel | ||
|
||
fun HTML.softwareSystemContainerSectionsPage(viewModel: SoftwareSystemContainerSectionsPageViewModel) { | ||
if (viewModel.visible) | ||
softwareSystemPage(viewModel) { | ||
div(classes = "tabs") { | ||
ul(classes = "m-0") { | ||
viewModel.sectionsTabs | ||
.forEach { | ||
li(classes = if (it.link.active) "is-active" else null) { | ||
link(it.link) | ||
} | ||
} | ||
} | ||
} | ||
table(viewModel.sectionsTable) | ||
} | ||
else | ||
redirectUpPage() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 22 additions & 2 deletions
24
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/views/SoftwareSystemSectionsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.