@bitbybit-dev/mcp 1.4.0 → 1.5.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/descriptions.d.ts.map +1 -1
- package/dist/descriptions.js +10 -5
- package/dist/descriptions.js.map +1 -1
- package/dist/guides-split.d.ts +6 -0
- package/dist/guides-split.d.ts.map +1 -1
- package/dist/guides-split.js +17 -3
- package/dist/guides-split.js.map +1 -1
- package/dist/guides.generated.d.ts +4 -3
- package/dist/guides.generated.d.ts.map +1 -1
- package/dist/guides.generated.js +249 -17
- package/dist/guides.generated.js.map +1 -1
- package/dist/index-loader.d.ts.map +1 -1
- package/dist/index-loader.js +10 -5
- package/dist/index-loader.js.map +1 -1
- package/dist/index-reader.d.ts +11 -1
- package/dist/index-reader.d.ts.map +1 -1
- package/dist/index-reader.js +87 -22
- package/dist/index-reader.js.map +1 -1
- package/dist/index-shape.d.ts.map +1 -1
- package/dist/index-shape.js +4 -2
- package/dist/index-shape.js.map +1 -1
- package/dist/index-types.d.ts +7 -0
- package/dist/index-types.d.ts.map +1 -1
- package/dist/index-url.d.ts.map +1 -1
- package/dist/index-url.js +2 -1
- package/dist/index-url.js.map +1 -1
- package/dist/installed-version.d.ts.map +1 -1
- package/dist/installed-version.js +14 -7
- package/dist/installed-version.js.map +1 -1
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/json-schema.js +16 -8
- package/dist/json-schema.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +6 -3
- package/dist/registry.js.map +1 -1
- package/dist/render.d.ts +3 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +55 -21
- package/dist/render.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -2
- package/dist/server.js.map +1 -1
- package/dist/stdio.js +4 -2
- package/dist/stdio.js.map +1 -1
- package/dist/tools/describe.d.ts.map +1 -1
- package/dist/tools/describe.js +13 -3
- package/dist/tools/describe.js.map +1 -1
- package/dist/tools/fetch.d.ts.map +1 -1
- package/dist/tools/fetch.js +3 -2
- package/dist/tools/fetch.js.map +1 -1
- package/dist/tools/get-examples.d.ts.map +1 -1
- package/dist/tools/get-examples.js +8 -4
- package/dist/tools/get-examples.js.map +1 -1
- package/dist/tools/get-guide.d.ts.map +1 -1
- package/dist/tools/get-guide.js +52 -7
- package/dist/tools/get-guide.js.map +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/__fixtures__/index.sample.json +261 -0
- package/src/__fixtures__/load.ts +1 -0
- package/src/descriptions.ts +10 -5
- package/src/guides-split.ts +27 -3
- package/src/guides.generated.ts +249 -17
- package/src/guides.test.ts +41 -7
- package/src/index-loader.test.ts +3 -1
- package/src/index-loader.ts +15 -5
- package/src/index-reader.ts +116 -21
- package/src/index-shape.ts +6 -2
- package/src/index-types.ts +8 -0
- package/src/index-url.ts +3 -1
- package/src/installed-version.test.ts +3 -1
- package/src/installed-version.ts +21 -7
- package/src/json-schema.ts +21 -7
- package/src/registry.ts +9 -3
- package/src/render.test.ts +153 -1
- package/src/render.ts +78 -20
- package/src/server.ts +6 -2
- package/src/stdio.test.ts +15 -5
- package/src/stdio.ts +6 -2
- package/src/tools/describe.ts +13 -3
- package/src/tools/docs-tools.test.ts +57 -1
- package/src/tools/fetch.ts +4 -2
- package/src/tools/get-examples.ts +12 -4
- package/src/tools/get-guide.ts +54 -7
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"babylon",
|
|
17
17
|
"babylon.meshBuilder",
|
|
18
18
|
"draw",
|
|
19
|
+
"ifc",
|
|
20
|
+
"ifc.model",
|
|
19
21
|
"math",
|
|
20
22
|
"occt",
|
|
21
23
|
"occt.fillets",
|
|
@@ -424,6 +426,87 @@
|
|
|
424
426
|
"playcanvas": "drawAnyAsync(inputs: Inputs.Draw.DrawAny<pc.Entity, E>): Promise<Inputs.Draw.Drawn<E, Inputs.Draw.BitByBitEntity>>"
|
|
425
427
|
}
|
|
426
428
|
},
|
|
429
|
+
{
|
|
430
|
+
"path": "ifc",
|
|
431
|
+
"kind": "namespace",
|
|
432
|
+
"name": "ifc",
|
|
433
|
+
"className": "IFCW",
|
|
434
|
+
"signature": null,
|
|
435
|
+
"async": false,
|
|
436
|
+
"params": [],
|
|
437
|
+
"returns": null,
|
|
438
|
+
"summary": "IFC building models as reached from a script: every method of the `ifc` worker, asynchronous, with models living in the worker and passed around as references, plus `geometry.toShapes`, `geometry.toDocument` and `geometry.toStep`, which build a model's elements with OpenCascade.",
|
|
439
|
+
"doc": "IFC building models as reached from a script: every method of the `ifc` worker, asynchronous,\nwith models living in the worker and passed around as references, plus `geometry.toShapes`,\n`geometry.toDocument` and `geometry.toStep`, which build a model's elements with OpenCascade.\nExperimental, as the IFC library is.",
|
|
440
|
+
"docUrl": "https://docs.bitbybit.dev/classes/Bit.IFCW",
|
|
441
|
+
"engines": [
|
|
442
|
+
"babylonjs",
|
|
443
|
+
"threejs",
|
|
444
|
+
"playcanvas"
|
|
445
|
+
],
|
|
446
|
+
"tier": "oss",
|
|
447
|
+
"onApi3d": false,
|
|
448
|
+
"weight": null,
|
|
449
|
+
"examples": []
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"path": "ifc.model",
|
|
453
|
+
"kind": "namespace",
|
|
454
|
+
"name": "model",
|
|
455
|
+
"className": "IFCModels",
|
|
456
|
+
"signature": null,
|
|
457
|
+
"async": false,
|
|
458
|
+
"params": [],
|
|
459
|
+
"returns": null,
|
|
460
|
+
"summary": "Creates, reads, writes and inspects whole IFC models.",
|
|
461
|
+
"doc": "Creates, reads, writes and inspects whole IFC models. A model is a value: every method that\nchanges one returns a new model and leaves the one it was given as it was, so a change can be\nundone by keeping the earlier model.\n\nObjects are found by their GlobalId or by the id given when they were added, such as `north-wall`,\nwhich the model turns into a GlobalId of its own. Storeys are in `spatial`, building elements in\n`walls`, `slabs`, `doors` and the rest.",
|
|
462
|
+
"docUrl": "https://docs.bitbybit.dev/classes/Bit.IFCModels",
|
|
463
|
+
"engines": [
|
|
464
|
+
"babylonjs",
|
|
465
|
+
"threejs",
|
|
466
|
+
"playcanvas"
|
|
467
|
+
],
|
|
468
|
+
"tier": "oss",
|
|
469
|
+
"onApi3d": false,
|
|
470
|
+
"weight": null,
|
|
471
|
+
"examples": []
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"path": "ifc.model.summary",
|
|
475
|
+
"kind": "method",
|
|
476
|
+
"name": "summary",
|
|
477
|
+
"className": "IFCModels",
|
|
478
|
+
"signature": "summary(inputs: Inputs.IFC.ModelDto<Inputs.IFC.IfcModelPointer>): Promise<Inputs.IFC.ModelSummaryDto>",
|
|
479
|
+
"async": true,
|
|
480
|
+
"params": [
|
|
481
|
+
{
|
|
482
|
+
"name": "inputs",
|
|
483
|
+
"type": "Inputs.IFC.ModelDto<Inputs.IFC.IfcModelPointer>",
|
|
484
|
+
"optional": false,
|
|
485
|
+
"fields": [
|
|
486
|
+
{
|
|
487
|
+
"name": "model",
|
|
488
|
+
"type": "Inputs.IFC.IfcModelPointer",
|
|
489
|
+
"optional": false,
|
|
490
|
+
"doc": "The model to read, as `model.create` or `model.read` returned it."
|
|
491
|
+
}
|
|
492
|
+
]
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
"returns": "Inputs.IFC.ModelSummaryDto",
|
|
496
|
+
"summary": "Describes what a model holds: its schema, its project, its unit, its storeys and how many elements of each type.",
|
|
497
|
+
"doc": "Describes what a model holds: its schema, its project, its unit, its storeys and how many\nelements of each type.",
|
|
498
|
+
"docUrl": "https://docs.bitbybit.dev/classes/Bit.IFCModels#summary",
|
|
499
|
+
"engines": [
|
|
500
|
+
"babylonjs",
|
|
501
|
+
"threejs",
|
|
502
|
+
"playcanvas"
|
|
503
|
+
],
|
|
504
|
+
"tier": "oss",
|
|
505
|
+
"onApi3d": false,
|
|
506
|
+
"weight": null,
|
|
507
|
+
"examples": [],
|
|
508
|
+
"group": "query"
|
|
509
|
+
},
|
|
427
510
|
{
|
|
428
511
|
"path": "math",
|
|
429
512
|
"kind": "namespace",
|
|
@@ -1851,6 +1934,184 @@
|
|
|
1851
1934
|
]
|
|
1852
1935
|
}
|
|
1853
1936
|
},
|
|
1937
|
+
"types": {
|
|
1938
|
+
"Inputs.IFC.ModelSummaryDto": {
|
|
1939
|
+
"name": "ModelSummaryDto",
|
|
1940
|
+
"summary": "What a model holds, as `model.summary` describes it.",
|
|
1941
|
+
"doc": "What a model holds, as `model.summary` describes it.",
|
|
1942
|
+
"fields": [
|
|
1943
|
+
{
|
|
1944
|
+
"name": "schema",
|
|
1945
|
+
"type": "string",
|
|
1946
|
+
"optional": false,
|
|
1947
|
+
"doc": "The schema the model's file names, such as `IFC4`.",
|
|
1948
|
+
"default": ""
|
|
1949
|
+
},
|
|
1950
|
+
{
|
|
1951
|
+
"name": "editable",
|
|
1952
|
+
"type": "boolean",
|
|
1953
|
+
"optional": false,
|
|
1954
|
+
"doc": "Whether the model can be changed: false for an `IFC2X3` file, which is read through `IFC4`\nto be shown and queried.",
|
|
1955
|
+
"default": true
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
"name": "project",
|
|
1959
|
+
"type": "string",
|
|
1960
|
+
"optional": false,
|
|
1961
|
+
"doc": "What the project is called.",
|
|
1962
|
+
"default": ""
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
"name": "millimetresPerUnit",
|
|
1966
|
+
"type": "number",
|
|
1967
|
+
"optional": false,
|
|
1968
|
+
"doc": "How many millimetres one length unit of the model is.",
|
|
1969
|
+
"default": 1
|
|
1970
|
+
},
|
|
1971
|
+
{
|
|
1972
|
+
"name": "entities",
|
|
1973
|
+
"type": "number",
|
|
1974
|
+
"optional": false,
|
|
1975
|
+
"doc": "How many entities the model holds, geometry and relationships included.",
|
|
1976
|
+
"default": 0
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
"name": "storeys",
|
|
1980
|
+
"type": "StoreyInfoDto[]",
|
|
1981
|
+
"optional": false,
|
|
1982
|
+
"doc": "The storeys, lowest first.",
|
|
1983
|
+
"default": []
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
"name": "elementCounts",
|
|
1987
|
+
"type": "Record<string, number>",
|
|
1988
|
+
"optional": false,
|
|
1989
|
+
"doc": "How many elements of each IFC type the model holds, such as `{ IfcWall: 8 }`.",
|
|
1990
|
+
"default": {}
|
|
1991
|
+
}
|
|
1992
|
+
]
|
|
1993
|
+
},
|
|
1994
|
+
"Inputs.IFC.StoreyInfoDto": {
|
|
1995
|
+
"name": "StoreyInfoDto",
|
|
1996
|
+
"summary": "A storey as `spatial.storeys` and `model.summary` list it: its GlobalId, name and elevation.",
|
|
1997
|
+
"doc": "A storey as `spatial.storeys` and `model.summary` list it: its GlobalId, name and elevation.",
|
|
1998
|
+
"fields": [
|
|
1999
|
+
{
|
|
2000
|
+
"name": "globalId",
|
|
2001
|
+
"type": "string",
|
|
2002
|
+
"optional": false,
|
|
2003
|
+
"doc": "The GlobalId that identifies the storey.",
|
|
2004
|
+
"default": ""
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
"name": "name",
|
|
2008
|
+
"type": "string",
|
|
2009
|
+
"optional": false,
|
|
2010
|
+
"doc": "What the storey is called.",
|
|
2011
|
+
"default": ""
|
|
2012
|
+
},
|
|
2013
|
+
{
|
|
2014
|
+
"name": "elevation",
|
|
2015
|
+
"type": "number",
|
|
2016
|
+
"optional": false,
|
|
2017
|
+
"doc": "How high its floor is above the building's origin, in the model's length unit.",
|
|
2018
|
+
"default": 0
|
|
2019
|
+
}
|
|
2020
|
+
]
|
|
2021
|
+
},
|
|
2022
|
+
"Inputs.OCCT.DecomposedManifoldMeshDto": {
|
|
2023
|
+
"name": "DecomposedManifoldMeshDto",
|
|
2024
|
+
"summary": "An indexed triangle mesh as `shapeToManifoldMesh` returns it, in the form `manifold.shapes.manifoldFromMesh` takes: the vertex positions and the triangles that index them.",
|
|
2025
|
+
"doc": "An indexed triangle mesh as `shapeToManifoldMesh` returns it, in the form\n`manifold.shapes.manifoldFromMesh` takes: the vertex positions and the triangles that index them.",
|
|
2026
|
+
"fields": [
|
|
2027
|
+
{
|
|
2028
|
+
"name": "numProp",
|
|
2029
|
+
"type": "number",
|
|
2030
|
+
"optional": false,
|
|
2031
|
+
"doc": "How many numbers each vertex carries in `vertProperties`: 3, its position."
|
|
2032
|
+
},
|
|
2033
|
+
{
|
|
2034
|
+
"name": "vertProperties",
|
|
2035
|
+
"type": "Float32Array",
|
|
2036
|
+
"optional": false,
|
|
2037
|
+
"doc": "The x, y and z of every vertex, one vertex after another."
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
"name": "triVerts",
|
|
2041
|
+
"type": "Uint32Array",
|
|
2042
|
+
"optional": false,
|
|
2043
|
+
"doc": "The triangles as vertex indexes, three per triangle, wound so that they face out of the shape."
|
|
2044
|
+
}
|
|
2045
|
+
]
|
|
2046
|
+
},
|
|
2047
|
+
"Inputs.Manifold.DecomposedManifoldMeshDto": {
|
|
2048
|
+
"name": "DecomposedManifoldMeshDto",
|
|
2049
|
+
"summary": "A Manifold solid taken apart into plain arrays - vertex properties, triangle indices and the run structure that groups them.",
|
|
2050
|
+
"doc": "A Manifold solid taken apart into plain arrays - vertex properties, triangle indices and the\nrun structure that groups them. The form the kernel hands back when geometry has to cross out of\nWebAssembly for rendering or export.",
|
|
2051
|
+
"fields": [
|
|
2052
|
+
{
|
|
2053
|
+
"name": "numProp",
|
|
2054
|
+
"type": "number",
|
|
2055
|
+
"optional": false,
|
|
2056
|
+
"doc": "How many numbers each vertex carries in `vertProperties`; the position takes the first three."
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
"name": "vertProperties",
|
|
2060
|
+
"type": "Float32Array",
|
|
2061
|
+
"optional": false,
|
|
2062
|
+
"doc": "All vertex properties in one flat list, `numProp` numbers per vertex, position first."
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
"name": "triVerts",
|
|
2066
|
+
"type": "Uint32Array",
|
|
2067
|
+
"optional": false,
|
|
2068
|
+
"doc": "The triangles as a flat list of vertex indexes, three per triangle."
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
"name": "mergeFromVert",
|
|
2072
|
+
"type": "Uint32Array",
|
|
2073
|
+
"optional": true,
|
|
2074
|
+
"doc": "For each merged vertex, the index of the property vertex that is merged away; pairs with\n`mergeToVert`."
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
"name": "mergeToVert",
|
|
2078
|
+
"type": "Uint32Array",
|
|
2079
|
+
"optional": true,
|
|
2080
|
+
"doc": "For each merged vertex, the index of the property vertex it is merged into; pairs with\n`mergeFromVert`."
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
"name": "runIndex",
|
|
2084
|
+
"type": "Uint32Array",
|
|
2085
|
+
"optional": true,
|
|
2086
|
+
"doc": "Where each triangle run starts in `triVerts`, one entry per run plus a final end marker."
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
"name": "runOriginalID",
|
|
2090
|
+
"type": "Uint32Array",
|
|
2091
|
+
"optional": true,
|
|
2092
|
+
"doc": "The id of the original shape each run of triangles came from, one per run."
|
|
2093
|
+
},
|
|
2094
|
+
{
|
|
2095
|
+
"name": "runTransform",
|
|
2096
|
+
"type": "Float32Array",
|
|
2097
|
+
"optional": true,
|
|
2098
|
+
"doc": "The placement of each run as 12 numbers of a column-major 3x4 matrix, one per run."
|
|
2099
|
+
},
|
|
2100
|
+
{
|
|
2101
|
+
"name": "faceID",
|
|
2102
|
+
"type": "Uint32Array",
|
|
2103
|
+
"optional": true,
|
|
2104
|
+
"doc": "For each triangle, the id of the flat face it belongs to, so coplanar triangles can be\ngrouped."
|
|
2105
|
+
},
|
|
2106
|
+
{
|
|
2107
|
+
"name": "halfedgeTangent",
|
|
2108
|
+
"type": "Float32Array",
|
|
2109
|
+
"optional": true,
|
|
2110
|
+
"doc": "The smoothing tangent of each half-edge as four numbers, direction and weight, when the solid\nwas smoothed."
|
|
2111
|
+
}
|
|
2112
|
+
]
|
|
2113
|
+
}
|
|
2114
|
+
},
|
|
1854
2115
|
"examples": {
|
|
1855
2116
|
"babylon.meshBuilder.createBox#1": {
|
|
1856
2117
|
"path": "babylon.meshBuilder.createBox",
|
package/src/__fixtures__/load.ts
CHANGED
|
@@ -22,6 +22,7 @@ export const FIXTURE_GUIDES: readonly GuideSection[] = [
|
|
|
22
22
|
{ id: "the-honest-default", title: "The honest default", level: 3, body: "The packages are the whole answer." },
|
|
23
23
|
{ id: "browser-apps", title: "Browser apps", level: 3, body: "The kernels run in the tab." },
|
|
24
24
|
{ id: "get-started", title: "Get started", level: 2, body: "Scaffold a project." },
|
|
25
|
+
{ id: "what-a-design-document-is", title: "What a design document is", level: 2, body: "A parametric model as JSON.", page: "https://example.test/design" },
|
|
25
26
|
];
|
|
26
27
|
|
|
27
28
|
export function fixtureContext(): DocsContext {
|
package/src/descriptions.ts
CHANGED
|
@@ -23,6 +23,7 @@ export const DESCRIPTIONS: Readonly<Record<ToolName, { title: string; descriptio
|
|
|
23
23
|
description:
|
|
24
24
|
"The exact contract of one member by dotted path, for example occt.shapes.solid.createBox: signature, every parameter with its type, default and range, " +
|
|
25
25
|
"the return type, the documentation, examples and where it runs. Answers are for the API version the server holds. " +
|
|
26
|
+
"It also describes the types a member returns or takes by their name, for example Inputs.IFC.SpaceInfoDto, field by field, and a member's answer lists those types. " +
|
|
26
27
|
"An unknown path is reported as not found together with the nearest existing paths; nothing is guessed.",
|
|
27
28
|
},
|
|
28
29
|
list_namespace: {
|
|
@@ -38,10 +39,11 @@ export const DESCRIPTIONS: Readonly<Record<ToolName, { title: string; descriptio
|
|
|
38
39
|
"Examples are written for the API version the server holds.",
|
|
39
40
|
},
|
|
40
41
|
get_guide: {
|
|
41
|
-
title: "Read the
|
|
42
|
+
title: "Read the guides",
|
|
42
43
|
description:
|
|
43
|
-
"Sections of the public
|
|
44
|
-
"Without a topic it lists the sections. Read \"integrate\" before recommending where geometry should run: the npm packages are the default, and CAD Cloud is for algorithms that exist only there or compute the caller cannot provide."
|
|
44
|
+
"Sections of the public guides: building with Bitbybit (what runs in the browser, on a server, on a lightweight backend, and what needs CAD Cloud), writing geometry with the kernels (which kernel to use, the order to build a part in, choosing edges, checking and exporting shapes), writing design documents (parametric models as JSON: parameters, sketches, features, references, parts and assemblies), and writing IFC building models (storeys, walls and their joins, doors, windows, slabs, roofs, rooms, properties and quantities). " +
|
|
45
|
+
"Without a topic it lists the sections. Read \"integrate\" before recommending where geometry should run: the npm packages are the default, and CAD Cloud is for algorithms that exist only there or compute the caller cannot provide. " +
|
|
46
|
+
"Read \"geometry\" before writing geometry code, \"design\" before writing a design document, and \"ifc\" before writing an IFC model.",
|
|
45
47
|
},
|
|
46
48
|
search: {
|
|
47
49
|
title: "Search",
|
|
@@ -56,7 +58,10 @@ export const DESCRIPTIONS: Readonly<Record<ToolName, { title: string; descriptio
|
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
export const SERVER_INSTRUCTIONS =
|
|
59
|
-
"This is the Bitbybit CAD MCP: it documents the Bitbybit 3D CAD API (OpenCascade, JSCAD and Manifold kernels, with Babylon.js, three.js and PlayCanvas renderers) for one exact version. " +
|
|
61
|
+
"This is the Bitbybit CAD MCP: it documents the Bitbybit 3D CAD API (OpenCascade, JSCAD and Manifold kernels, with Babylon.js, three.js and PlayCanvas renderers, and the IFC library for building models) for one exact version. " +
|
|
60
62
|
"Always describe a member before using it: names, parameters and defaults come from the index, not from memory. " +
|
|
61
63
|
"Tiers matter: oss members are in the MIT npm packages and run anywhere; platform-pro members exist only inside bitbybit.dev; cloud-pro members run only on Bitbybit CAD Cloud with an API key. " +
|
|
62
|
-
"When asked where geometry should run, read get_guide(\"integrate\") first: the packages alone are the default, and CAD Cloud is the answer only for algorithms that exist only there or for compute the caller cannot provide."
|
|
64
|
+
"When asked where geometry should run, read get_guide(\"integrate\") first: the packages alone are the default, and CAD Cloud is the answer only for algorithms that exist only there or for compute the caller cannot provide. " +
|
|
65
|
+
"Before writing geometry code with the occt, manifold or jscad kernels, read get_guide(\"geometry\"), then get_guide(\"part-order\") and get_guide(\"geometry-mistakes\"). " +
|
|
66
|
+
"Before writing a design document, a parametric model as JSON that occt.design builds, read get_guide(\"design\") and the sections it lists. " +
|
|
67
|
+
"Before writing an IFC building model with the ifc namespace, read get_guide(\"ifc\"), then get_guide(\"ifc-order\") and get_guide(\"ifc-mistakes\").";
|
package/src/guides-split.ts
CHANGED
|
@@ -3,6 +3,12 @@ export interface GuideSection {
|
|
|
3
3
|
title: string;
|
|
4
4
|
level: 2 | 3;
|
|
5
5
|
body: string;
|
|
6
|
+
page?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface GuidePage {
|
|
10
|
+
url: string;
|
|
11
|
+
markdown: string;
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
const FRONTMATTER = /^---\n[\s\S]*?\n---\n/;
|
|
@@ -22,7 +28,9 @@ export function splitGuides(markdown: string): GuideSection[] {
|
|
|
22
28
|
const close = (minLevel: number): void => {
|
|
23
29
|
while (open.length > 0) {
|
|
24
30
|
const last = open[open.length - 1];
|
|
25
|
-
if (!last || last.section.level < minLevel)
|
|
31
|
+
if (!last || last.section.level < minLevel) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
26
34
|
last.section.body = last.lines.join("\n").trim();
|
|
27
35
|
open.pop();
|
|
28
36
|
}
|
|
@@ -33,14 +41,30 @@ export function splitGuides(markdown: string): GuideSection[] {
|
|
|
33
41
|
const level = heading[1] === "##" ? 2 : 3;
|
|
34
42
|
const title = (heading[2] ?? "").trim();
|
|
35
43
|
close(level);
|
|
36
|
-
for (const entry of open)
|
|
44
|
+
for (const entry of open) {
|
|
45
|
+
entry.lines.push(line);
|
|
46
|
+
}
|
|
37
47
|
const section: GuideSection = { id: slugify(title), title, level, body: "" };
|
|
38
48
|
sections.push(section);
|
|
39
49
|
open.push({ section, lines: [] });
|
|
40
50
|
continue;
|
|
41
51
|
}
|
|
42
|
-
for (const entry of open)
|
|
52
|
+
for (const entry of open) {
|
|
53
|
+
entry.lines.push(line);
|
|
54
|
+
}
|
|
43
55
|
}
|
|
44
56
|
close(2);
|
|
45
57
|
return sections;
|
|
46
58
|
}
|
|
59
|
+
|
|
60
|
+
export function splitGuidePages(pages: readonly GuidePage[]): GuideSection[] {
|
|
61
|
+
const sections = pages.flatMap((page) => splitGuides(page.markdown).map((section) => ({ ...section, page: page.url })));
|
|
62
|
+
const seen = new Set<string>();
|
|
63
|
+
for (const section of sections) {
|
|
64
|
+
if (seen.has(section.id)) {
|
|
65
|
+
throw new Error(`Two guide sections share the id "${section.id}"; retitle one of them so every section has its own id`);
|
|
66
|
+
}
|
|
67
|
+
seen.add(section.id);
|
|
68
|
+
}
|
|
69
|
+
return sections;
|
|
70
|
+
}
|