Merge documentation-branch, regenerate documentation
This commit is contained in:
commit
4f7f93e9c1
121 changed files with 17652 additions and 1477 deletions
|
@ -8,6 +8,7 @@ import List from "../UI/Base/List";
|
|||
import DependencyCalculator from "../Models/ThemeConfig/DependencyCalculator";
|
||||
import Constants from "../Models/Constants";
|
||||
import {Utils} from "../Utils";
|
||||
import Link from "../UI/Base/Link";
|
||||
|
||||
export class AllKnownLayouts {
|
||||
// Must be below the list...
|
||||
|
@ -52,14 +53,9 @@ export class AllKnownLayouts {
|
|||
}
|
||||
return allLayers
|
||||
}
|
||||
|
||||
public static GenLayerOverviewText(): BaseUIElement {
|
||||
for (const id of Constants.priviliged_layers) {
|
||||
if (!AllKnownLayouts.sharedLayers.has(id)) {
|
||||
throw "Priviliged layer definition not found: " + id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static GenOverviewsForSingleLayer(callback: (layer: LayerConfig, element: BaseUIElement) => void): void {
|
||||
const allLayers: LayerConfig[] = Array.from(AllKnownLayouts.sharedLayers.values())
|
||||
.filter(layer => Constants.priviliged_layers.indexOf(layer.id) < 0)
|
||||
|
||||
|
@ -84,10 +80,54 @@ export class AllKnownLayouts {
|
|||
}
|
||||
|
||||
|
||||
let popularLayerCutoff = 2;
|
||||
const popuparLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length >= 2)
|
||||
// Determine the cross-dependencies
|
||||
const layerIsNeededBy : Map<string, string[]> = new Map<string, string[]>()
|
||||
|
||||
for (const layer of allLayers) {
|
||||
for (const dep of DependencyCalculator.getLayerDependencies(layer)) {
|
||||
const dependency = dep.neededLayer
|
||||
if(!layerIsNeededBy.has(dependency)){
|
||||
layerIsNeededBy.set(dependency, [])
|
||||
}
|
||||
layerIsNeededBy.get(dependency).push(layer.id)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
allLayers.forEach((layer) => {
|
||||
const element = layer.GenerateDocumentation(themesPerLayer.get(layer.id),layerIsNeededBy,DependencyCalculator.getLayerDependencies(layer))
|
||||
callback(layer, element)
|
||||
})
|
||||
}
|
||||
|
||||
public static GenLayerOverviewText(): BaseUIElement {
|
||||
for (const id of Constants.priviliged_layers) {
|
||||
if (!AllKnownLayouts.sharedLayers.has(id)) {
|
||||
throw "Priviliged layer definition not found: " + id
|
||||
}
|
||||
}
|
||||
|
||||
const allLayers: LayerConfig[] = Array.from(AllKnownLayouts.sharedLayers.values())
|
||||
.filter(layer => Constants.priviliged_layers.indexOf(layer.id) < 0)
|
||||
|
||||
const builtinLayerIds: Set<string> = new Set<string>()
|
||||
allLayers.forEach(l => builtinLayerIds.add(l.id))
|
||||
|
||||
const themesPerLayer = new Map<string, string[]>()
|
||||
|
||||
for (const layout of Array.from(AllKnownLayouts.allKnownLayouts.values())) {
|
||||
for (const layer of layout.layers) {
|
||||
if (!builtinLayerIds.has(layer.id)) {
|
||||
continue
|
||||
}
|
||||
if (!themesPerLayer.has(layer.id)) {
|
||||
themesPerLayer.set(layer.id, [])
|
||||
}
|
||||
themesPerLayer.get(layer.id).push(layout.id)
|
||||
}
|
||||
}
|
||||
|
||||
const unpopularLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length < 2)
|
||||
|
||||
// Determine the cross-dependencies
|
||||
const layerIsNeededBy : Map<string, string[]> = new Map<string, string[]>()
|
||||
|
@ -104,6 +144,8 @@ export class AllKnownLayouts {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new Combine([
|
||||
new Title("Special and other useful layers", 1),
|
||||
"MapComplete has a few data layers available in the theme which have special properties through builtin-hooks. Furthermore, there are some normal layers (which are built from normal Theme-config files) but are so general that they get a mention here.",
|
||||
|
@ -113,14 +155,8 @@ export class AllKnownLayouts {
|
|||
.map(id => AllKnownLayouts.sharedLayers.get(id))
|
||||
.map((l) => l.GenerateDocumentation(themesPerLayer.get(l.id), layerIsNeededBy, DependencyCalculator.getLayerDependencies(l),Constants.added_by_default.indexOf(l.id) >= 0, Constants.no_include.indexOf(l.id) < 0)),
|
||||
new Title("Normal layers", 1),
|
||||
"The following layers are included in MapComplete",
|
||||
new Title("Frequently reused layers", 2),
|
||||
"The following layers are used by at least " + popularLayerCutoff + " mapcomplete themes and might be interesting for your custom theme too",
|
||||
new List(popuparLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
|
||||
...popuparLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id),layerIsNeededBy,DependencyCalculator.getLayerDependencies(layer))),
|
||||
new List(unpopularLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
|
||||
...unpopularLayers.map(layer => layer.GenerateDocumentation(themesPerLayer.get(layer.id),layerIsNeededBy,DependencyCalculator.getLayerDependencies(layer))
|
||||
)
|
||||
"The following layers are included in MapComplete:",
|
||||
new List(Array.from(AllKnownLayouts.sharedLayers.keys()).map(id => new Link(id, "./Layers/"+id+".md")))
|
||||
])
|
||||
|
||||
|
||||
|
@ -128,7 +164,7 @@ export class AllKnownLayouts {
|
|||
|
||||
private static GenerateOrderedList(allKnownLayouts: Map<string, LayoutConfig>): LayoutConfig[] {
|
||||
const list = []
|
||||
allKnownLayouts.forEach((layout, key) => {
|
||||
allKnownLayouts.forEach((layout) => {
|
||||
list.push(layout)
|
||||
})
|
||||
return list;
|
||||
|
@ -144,7 +180,8 @@ export class AllKnownLayouts {
|
|||
for (let i = 0; i < layout.layers.length; i++) {
|
||||
let layer = layout.layers[i];
|
||||
if (typeof (layer) === "string") {
|
||||
layer = layout.layers[i] = AllKnownLayouts.sharedLayers.get(layer);
|
||||
layer = AllKnownLayouts.sharedLayers.get(layer);
|
||||
layout.layers[i] = layer
|
||||
if (layer === undefined) {
|
||||
console.log("Defined layers are ", AllKnownLayouts.sharedLayers.keys())
|
||||
throw `Layer ${layer} was not found or defined - probably a type was made`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue