Skip to content

Commit

Permalink
Documentation checkpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
rerdavies committed Jan 13, 2025
1 parent 5960bd7 commit d572981
Show file tree
Hide file tree
Showing 37 changed files with 4,193 additions and 963 deletions.
9 changes: 5 additions & 4 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ cmake_minimum_required(VERSION 3.14)

# Only add the custom target for release builds

set(BUILD_DIR "./dist")

if(CMAKE_BUILD_TYPE STREQUAL "Release"
OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_custom_target(build_docs ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/index.html
DEPENDS ${BUILD_DIR}/index.html
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index.html
OUTPUT ${BUILD_DIR}/index.html

COMMAND npm run build
COMMAND ./make_route_pages.sh ${CMAKE_CURRENT_BINARY_DIR}
# BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/dist/index.html
COMMAND ./make_route_pages.sh ${BUILD_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building Vite React website"

Expand Down
14 changes: 14 additions & 0 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"@fontsource/roboto": "^5.1.0",
"@mui/icons-material": "^6.3.0",
"@mui/material": "^6.3.0",
"@types/moo": "^0.5.10",
"moo": "^0.5.2",
"react": "^18.3.1",
"react-code-blocks": "^0.1.6",
"react-dom": "^18.3.1",
Expand Down
14 changes: 14 additions & 0 deletions docs/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ button:focus, button:focus-visible {
color: #333;
background: #D0D0D0
}
.index_link {
text-decoration: normal;
cursor: pointer;
}
.index_link::after {
content: "🔗";
font-size: 0.8em;
margin-left: 0px;
}
.index_link:hover {
text-decoration: underline;
}


.name {
Expand Down Expand Up @@ -281,11 +293,13 @@ h1 {
flex-flow: row wrap;
gap: 8px;
justify-content: space-between;
align-items: baseline;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc;
margin-bottom: 8px;
padding-right: 16px;
margin-top: 32px;
line-height: 1;
}

.material-icon-inline {
Expand Down
121 changes: 78 additions & 43 deletions docs/src/ClassDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import React from "react";
import { RegisterIndexEntry } from "./IndexBuilder";
import { Link } from "react-router-dom";
import {IL} from "./M";

export default function
ClassDescription(props: {
children: React.ReactNode,
children?: React.ReactNode,
name: string,
prefix?: string,
id_tag?: string,
Expand All @@ -45,7 +46,7 @@ export default function
<div id={id} className="nav_target" >
<h2 className="class-desc-header" >
<div>{prefix} {props.name}</div>
{props.baseClass && <div>extends {props.baseClass}</div>}
{props.baseClass && <div style={{opacity: 0.6,marginLeft: 32 }}>extends {props.baseClass}</div>}
</h2>

<div style={{ marginLeft: 32, marginRight: 16 }}>
Expand Down Expand Up @@ -91,6 +92,28 @@ export function PropertyList(props: { children?: React.ReactNode }) {
);
}

export function FieldEntry(props: { name: string, type: string, children?: React.ReactNode }) {
let pos = props.name.indexOf("::");
let id = undefined;
let classNameOnly = "";
let propertyOnly = props.name;
if (pos >= 0) {
classNameOnly = props.name.substring(0, pos);
propertyOnly = props.name.substring(pos + 2);
id = "field__" + classNameOnly + "_" + propertyOnly;
}
if (id) {
RegisterIndexEntry(propertyOnly, id, "field " + props.name);
}
return (
<React.Fragment>
<div className="property_grid_cell_pre"><IL name={props.type}/></div>
<div className="property_grid_cell_pre" id={id}>{propertyOnly}</div>
<div className="property_grid_cell">{props.children}</div>
</React.Fragment>
);
}

export function PropertyEntry(props: { propertyName: string, type: string, children?: React.ReactNode }) {
let pos = props.propertyName.indexOf("::");
let id = undefined;
Expand All @@ -106,7 +129,7 @@ export function PropertyEntry(props: { propertyName: string, type: string, child
}
return (
<React.Fragment>
<div className="property_grid_cell_pre">{props.type}</div>
<div className="property_grid_cell_pre"><IL name={props.type}/></div>
<div className="property_grid_cell_pre" id={id}>{propertyOnly}</div>
<div className="property_grid_cell">{props.children}</div>
</React.Fragment>
Expand All @@ -133,44 +156,42 @@ function removeParametersAndClass(name: string) {
return name;

}

let eventRegexp = /\s(\w*\:\:\w*)$/;

let paramRegexp = /(\w+\:\:\w+(?:[+-=!<>T]+)?)(?:\(.*\))(?:\s*const\s*$)?/;
let methodParamRegexp = /(\w+)(?:\(.*\))(?:\s*const\s*$)?/;
let directIndexRegexp = /^(\w+\:\:\w+)$/;
let defineRegexp = /^(\w+)$/;
let constRegexp = /\s(\w+)$/;

function removeParameters(name: string) {
while (true) {
let matched = false;
if (name.startsWith("static ")) {
matched = true;
name = name.substring(7);
} else if (name.startsWith("virtual ")) {
matched = true;
name = name.substring(8);
}
else if (name.startsWith("const ")) {
matched = true;
name = name.substring(6);
} else if (name.startsWith("constexpr ")) {
matched = true;
name = name.substring(10);
}
if (!matched) {
break;
}
let match = name.match(eventRegexp);
if (match) {
return match[1];
}

let pos = name.indexOf(" ");
// remove the return type.
if (pos < 0) {
pos = 0;
match = name.match(paramRegexp);
if (match) {
return match[1];
}
while (pos < name.length && name[pos] == " " || name[pos] === '*' || name[pos] === '&') {
pos++;
match = name.match(methodParamRegexp);
if (match) {
return match[1];
}
{
name = name.substring(pos);
match = name.match(directIndexRegexp);
if (match) {
return name;
}
pos = name.indexOf("(");
if (pos >= 0) {
return name.substring(0, pos);
match = name.match(defineRegexp);
if (match) {
return name;
}
return name;
match = name.match(constRegexp);
if (match) {
return match[1];
}

throw new Error("Unable to match name: " + name);
}

export function ClassSectionHead(props: { text: string }) {
Expand Down Expand Up @@ -274,11 +295,11 @@ export function OperatorDescriptions(props: { children?: React.ReactNode }) {
}


export function EventDescription(props: { indexName: string | string[] | undefined, method: string, children?: React.ReactNode }) {
export function EventDescription(props: { indexName: string | string[] | undefined, event: string, children?: React.ReactNode }) {
return MethodDescription(
{
indexName: props.indexName,
method: props.method,
method: props.event,
tag: "event",
children: props.children
});
Expand Down Expand Up @@ -336,18 +357,31 @@ export function MethodDescription(
let tag = props.tag || "method";
let indexName = props.indexName;
let id = "";
let extraTargetLinks: React.ReactNode[] = [];
if (indexName) {
let ids = new Set<string>();

if (indexName instanceof Array) {
let indexArray = indexName as string[];
for (let name of indexArray) {
if (id.length > 0) {
id += "_";
}
id += methodId(tag, name);
let thisId = methodId(tag, name);
ids.add(thisId);
RegisterIndexEntry(removeParametersAndClass(name), thisId, tag + " " + name);

}

for (let name of indexArray) {
RegisterIndexEntry(removeParametersAndClass(name), id, tag + " " + name);
let first = true;
for (let thisId of ids) {
if (first)
{
id = thisId;
first = false;
} else {
extraTargetLinks.push((
<div id={thisId} key={thisId} style={{width: 0, height: 0}} >
</div>
));
}
}
} else {
let name = indexName as string;
Expand All @@ -358,6 +392,7 @@ export function MethodDescription(
return (
<div className="method_description" id={id.length > 0 ? id : undefined}>

{extraTargetLinks}
<pre className="mono" style={{ paddingLeft: "8px", paddingTop: "12px", paddingBottom: "12px", overflowX: "auto" }}>{props.method}</pre>
<div style={{ marginLeft: 24 }}>
{props.children}
Expand Down
Loading

0 comments on commit d572981

Please sign in to comment.