Skip to content

Commit 7a2e2a3

Browse files
fixed state
1 parent 4971e43 commit 7a2e2a3

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/docs/ filter=lfs diff=lfs merge=lfs -text
2+
core.autocrlf=true

files/.eslintrc.yml

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ rules:
9696
indent: [warn, 4, { SwitchCase: 1 }]
9797
key-spacing: warn
9898
keyword-spacing: warn
99-
linebreak-style: [warn, unix]
10099
new-parens: warn
101100
no-multi-spaces: [warn, { ignoreEOLComments: true }]
102101
no-multiple-empty-lines: warn

files/generate.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function parseInput(state) {
308308
scope = mergeObject(scope, newScope);
309309
}
310310

311-
return { navs, scope, base, baseKeys, state };
311+
return { navs, scope, base, baseKeys };
312312
}
313313

314314
/**
@@ -390,12 +390,15 @@ function generateDocs(inpt, state) {
390390

391391
if (!"tips".match(regGen)) return;
392392

393-
generateTips(inpt);
393+
generateTips(inpt, state);
394394
generateTsx(inpt);
395395
}
396396

397-
/** @param {DSInput} scope */
398-
function generateTips({ base, scope, state }) {
397+
/**
398+
* @param {DSInput} scope
399+
* @param {GenState} state
400+
*/
401+
function generateTips({ base, scope }, state) {
399402
state.curDoc = getSrcDir(D_VER, state, state.curScope + '-tips.json');
400403
/** @type {DSScopeRaw} */
401404
let tsubf;
@@ -473,7 +476,7 @@ function generateDoc(state, inpt, name) {
473476
if (dbg) app.UpdateProgressBar(state.progress, state.curScope + '.' + name + " get data");
474477

475478
const m = fillMissingFuncProps(ps);
476-
data = getDocData(inpt, m);
479+
data = getDocData(inpt, state, m);
477480
desc = m.desc;
478481

479482
// function line with popups
@@ -640,8 +643,8 @@ function adjustDoc(state, html, name) {
640643
function formatDesc(inpt, state, desc, name, hasData) {
641644
desc = desc.charAt(0).toUpperCase() + desc.slice(1);
642645

643-
const samplesJs = getSamples(inpt, name);
644-
const samplesPy = getSamples(inpt, name, "-py");
646+
const samplesJs = getSamples(inpt.scope, state, name);
647+
const samplesPy = getSamples(inpt.scope, state, name, "-py");
645648
let sampcnt = keys(samplesJs).length;
646649
if (!has(desc, '.')) desc += '.';
647650

@@ -670,9 +673,9 @@ function formatDesc(inpt, state, desc, name, hasData) {
670673
.replace(/\s*<br>\s*/g, "<br>\n\t\t")
671674
// expandable samples (per <sample name> tag or add to desc)
672675
.replace(/<sample (.*?)>/g, (m, /** @type {string} */ t) =>
673-
`</p>\n\t\t${toHtmlSamp(t, samplesJs[t], samplesPy[t], inpt.state) + (delete samplesJs[t], '')}<p>`)
676+
`</p>\n\t\t${toHtmlSamp(t, samplesJs[t], samplesPy[t], state) + (delete samplesJs[t], '')}<p>`)
674677
.replace(/(.*?)/g, "<docstr>$1</docstr>")
675-
+ keys(samplesJs).map(t => toHtmlSamp(t, samplesJs[t], samplesPy[t], inpt.state)).join("");
678+
+ keys(samplesJs).map(t => toHtmlSamp(t, samplesJs[t], samplesPy[t], state)).join("");
676679
}
677680

678681
/**
@@ -705,9 +708,10 @@ function fillMissingFuncProps(f) {
705708

706709
/** converts a function object into an html snippets object
707710
* @param {DSInput} inpt
711+
* @param {GenState} state
708712
* @param {DSMethod} f */
709-
function getDocData(inpt, f, useAppPop = false) {
710-
const { base, state } = inpt;
713+
function getDocData(inpt, state, f, useAppPop = false) {
714+
const { base } = inpt;
711715
/** @type {string[]} */
712716
const mArgs = [];
713717
let i, fretval = "";
@@ -801,11 +805,12 @@ function getDocData(inpt, f, useAppPop = false) {
801805
}
802806

803807
/** read and return html converted example snippets file
804-
* @param {DSInput} inpt
808+
* @param {DSScope} scope
809+
* @param {GenState} state
805810
* @param {string} func
806811
* @param {string} ext
807812
*/
808-
function getSamples({ scope, state }, func, ext = "") {
813+
function getSamples(scope, state, func, ext = "") {
809814
/** @type {Obj<Sample>} */
810815
const samples = {};
811816
let index = 0;
@@ -931,7 +936,7 @@ function typeDesc(inpt, state, stypes) {
931936
default:
932937
if (!type[0].endsWith("o"))
933938
Throw(Error("unknown typex " + type[1]));
934-
if (inpt.state.curDoc.endsWith(type[2] + ".htm"))
939+
if (state.curDoc.endsWith(type[2] + ".htm"))
935940
return s[i] + type[2];
936941
if (!type[2].startsWith("@") && !inpt.scope[type[2]])
937942
Throw(Error("link required for " + type[2]));
@@ -1016,7 +1021,7 @@ function toArgPop(inpt, state, name, stypes, doSwitch) {
10161021
default:
10171022
if (!type[0].endsWith("o"))
10181023
Throw(Error("unknown typex " + type[1]));
1019-
if (inpt.state.curDoc.endsWith(type[2] + ".htm"))
1024+
if (state.curDoc.endsWith(type[2] + ".htm"))
10201025
return s2[i] + type[2];
10211026
if (!type[2].startsWith("@") && !inpt.scope[type[2]])
10221027
Throw(Error("link required for " + type[2]));

files/types.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ declare global {
6565
type DSScope = Obj<DSFunction>;
6666
type DSBase = Obj<DSFunction>;
6767
type DSNavs = (string[] | Obj<string | DSNavs>) & { _nofilter?: boolean }
68-
type DSInput = { base: DSBase | null, baseKeys: string[], scope: DSScope, navs: DSNavs, state: GenState };
68+
type DSInput = { base: DSBase | null, baseKeys: string[], scope: DSScope, navs: DSNavs };
6969
type GenState = {
7070
lang: LangKeys, curVer: string, curDoc: string;
7171
curScope: ScopeKeys, curFunc: string, curSubf: string;

0 commit comments

Comments
 (0)