docs in sub package
This commit is contained in:
parent
29a5766d92
commit
010ee6baf1
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,5 +1,16 @@
|
||||
_docpress
|
||||
api/hooks/lib/app.server*
|
||||
node_modules
|
||||
media
|
||||
tmp
|
||||
frontend/dist
|
||||
_temp
|
||||
frontend/dist
|
||||
docs/node_modules
|
||||
yarn-error.log
|
||||
.yarn/*
|
||||
!.yarn/cache
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"markdown": {
|
||||
"plugins": {
|
||||
"code-include": {}
|
||||
}
|
||||
},
|
||||
"css": ["docs/docpress.css", "docs/github-dark-dimmed.css"]
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const INCLUDE_RE = /!{3}\s*include(.+?)!{3}/i;
|
||||
const BRACES_RE = /\((.+?)\)/i;
|
||||
|
||||
const include_plugin = (md, options) => {
|
||||
const defaultOptions = {
|
||||
root: '.',
|
||||
getRootDir: (pluginOptions/*, state, startLine, endLine*/) => pluginOptions.root,
|
||||
includeRe: INCLUDE_RE,
|
||||
throwError: false,
|
||||
bracesAreOptional: false,
|
||||
notFoundMessage: 'File \'{{FILE}}\' not found.',
|
||||
circularMessage: 'Circular reference between \'{{FILE}}\' and \'{{PARENT}}\'.'
|
||||
};
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
...defaultOptions,
|
||||
root: options
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
...defaultOptions,
|
||||
...options
|
||||
};
|
||||
}
|
||||
|
||||
const _replaceIncludeByContent = (src, rootdir, parentFilePath, filesProcessed) => {
|
||||
filesProcessed = filesProcessed ? filesProcessed.slice() : []; // making a copy
|
||||
let cap, filePath, mdSrc, errorMessage;
|
||||
|
||||
// store parent file path to check circular references
|
||||
if (parentFilePath) {
|
||||
filesProcessed.push(parentFilePath);
|
||||
}
|
||||
while ((cap = options.includeRe.exec(src))) {
|
||||
let includePath = cap[1].trim();
|
||||
const sansBracesMatch = BRACES_RE.exec(includePath);
|
||||
|
||||
if (!sansBracesMatch && !options.bracesAreOptional) {
|
||||
errorMessage = `INCLUDE statement '${src.trim()}' MUST have '()' braces around the include path ('${includePath}')`;
|
||||
} else if (sansBracesMatch) {
|
||||
includePath = sansBracesMatch[1].trim();
|
||||
} else if (!/^\s/.test(cap[1])) {
|
||||
// path SHOULD have been preceeded by at least ONE whitespace character!
|
||||
/* eslint max-len: "off" */
|
||||
errorMessage = `INCLUDE statement '${src.trim()}': when not using braces around the path ('${includePath}'), it MUST be preceeded by at least one whitespace character to separate the include keyword and the include path.`;
|
||||
}
|
||||
|
||||
if (!errorMessage) {
|
||||
filePath = path.resolve(rootdir, includePath);
|
||||
|
||||
// check if child file exists or if there is a circular reference
|
||||
if (!fs.existsSync(filePath)) {
|
||||
// child file does not exist
|
||||
errorMessage = options.notFoundMessage.replace('{{FILE}}', filePath);
|
||||
} else if (filesProcessed.indexOf(filePath) !== -1) {
|
||||
// reference would be circular
|
||||
errorMessage = options.circularMessage.replace('{{FILE}}', filePath).replace('{{PARENT}}', parentFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
// check if there were any errors
|
||||
if (errorMessage) {
|
||||
if (options.throwError) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
mdSrc = `\n\n# INCLUDE ERROR: ${errorMessage}\n\n`;
|
||||
} else {
|
||||
// get content of child file
|
||||
mdSrc = fs.readFileSync(filePath, 'utf8');
|
||||
// check if child file also has includes
|
||||
mdSrc = _replaceIncludeByContent(mdSrc, path.dirname(filePath), filePath, filesProcessed);
|
||||
// remove one trailing newline, if it exists: that way, the included content does NOT
|
||||
// automatically terminate the paragraph it is in due to the writer of the included
|
||||
// part having terminated the content with a newline.
|
||||
// However, when that snippet writer terminated with TWO (or more) newlines, these, minus one,
|
||||
// will be merged with the newline after the #include statement, resulting in a 2-NL paragraph
|
||||
// termination.
|
||||
const len = mdSrc.length;
|
||||
if (mdSrc[len - 1] === '\n') {
|
||||
mdSrc = mdSrc.substring(0, len - 1);
|
||||
}
|
||||
}
|
||||
|
||||
const labelStyle = `padding: 0 4px; font-size: 12px; font-weight: bold; color: #ffffff; background: #444444; opacity: .6;`
|
||||
|
||||
const fileLabel = `<div style="position:relative; height: 0px;"><div class="code-file-label" style="position:absolute; top: -10px;${labelStyle}">${includePath}</div></div>\n\n`
|
||||
const fileExt = includePath.replace(/^.+\./, "")
|
||||
|
||||
// replace include by file content
|
||||
src = src.slice(0, cap.index) + fileLabel + "```" + fileExt + "\n" + mdSrc + "\n```" + src.slice(cap.index + cap[0].length, src.length);
|
||||
}
|
||||
return src;
|
||||
};
|
||||
|
||||
const _includeFileParts = (state, startLine, endLine/*, silent*/) => {
|
||||
state.src = _replaceIncludeByContent(state.src, options.getRootDir(options, state, startLine, endLine));
|
||||
};
|
||||
|
||||
md.core.ruler.before('normalize', 'include', _includeFileParts);
|
||||
};
|
||||
|
||||
module.exports = include_plugin;
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "markdown-it-code-include",
|
||||
"version": "0.0.0",
|
||||
"description": "A markdown-it plugin to include code blocks.",
|
||||
"main": "./index.js",
|
||||
"scripts": {
|
||||
},
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"markdown-it",
|
||||
"markdown-it-plugin",
|
||||
"code-blocks",
|
||||
"fence"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"node-html-parser": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"markdown-it": "^12.0.0",
|
||||
"markdown-it-testgen": "^0.1.6",
|
||||
"path": "^0.12.7"
|
||||
}
|
||||
}
|
26
package.json
26
package.json
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "tibi-docs",
|
||||
"name": "tibi-demo",
|
||||
"version": "1.0.0",
|
||||
"main": "README.md",
|
||||
"repository": "https://gitbase.de/cms/tibi-docs",
|
||||
@ -19,8 +19,8 @@
|
||||
"upload:sourcemaps": "scripts/upload-sourcemaps.sh"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.20.7",
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/cli": "^7.21.0",
|
||||
"@babel/core": "^7.21.0",
|
||||
"@babel/preset-env": "^7.20.2",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"@types/lodash": "^4.14.191",
|
||||
@ -28,30 +28,30 @@
|
||||
"chokidar": "^3.5.3",
|
||||
"connect-history-api-fallback": "^2.0.0",
|
||||
"docpress": "^0.8.2",
|
||||
"esbuild": "^0.17.4",
|
||||
"esbuild": "^0.17.10",
|
||||
"esbuild-svelte": "^0.7.3",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"less": "^4.1.3",
|
||||
"morgan": "^1.10.0",
|
||||
"node-fetch": "^3.3.0",
|
||||
"postcss": "^8.4.21",
|
||||
"prettier": "^2.8.3",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier-plugin-svelte": "^2.9.0",
|
||||
"sass": "^1.57.1",
|
||||
"sass": "^1.58.3",
|
||||
"svelte": "^3.55.1",
|
||||
"svelte-check": "^3.0.2",
|
||||
"svelte-check": "^3.0.3",
|
||||
"svelte-hmr": "^0.15.1",
|
||||
"svelte-preprocess": "^5.0.1",
|
||||
"svelte-preprocess-esbuild": "^3.0.1",
|
||||
"svelte-routing": "^1.6.0",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.4"
|
||||
"tslib": "^2.5.0",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/browser": "^7.31.1",
|
||||
"@sentry/cli": "^2.11.0",
|
||||
"@sentry/tracing": "^7.31.1",
|
||||
"core-js": "3.27.2",
|
||||
"@sentry/browser": "^7.38.0",
|
||||
"@sentry/cli": "^2.13.0",
|
||||
"@sentry/tracing": "^7.38.0",
|
||||
"core-js": "3.28.0",
|
||||
"markdown-it-code-include": "./markdown-it-code-include"
|
||||
}
|
||||
}
|
||||
|
56
yarn.lock
56
yarn.lock
@ -15,7 +15,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/cli@npm:^7.20.7":
|
||||
"@babel/cli@npm:^7.21.0":
|
||||
version: 7.21.0
|
||||
resolution: "@babel/cli@npm:7.21.0"
|
||||
dependencies:
|
||||
@ -58,7 +58,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/core@npm:^7.20.12":
|
||||
"@babel/core@npm:^7.21.0":
|
||||
version: 7.21.0
|
||||
resolution: "@babel/core@npm:7.21.0"
|
||||
dependencies:
|
||||
@ -1557,7 +1557,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@sentry/browser@npm:^7.31.1":
|
||||
"@sentry/browser@npm:^7.38.0":
|
||||
version: 7.38.0
|
||||
resolution: "@sentry/browser@npm:7.38.0"
|
||||
dependencies:
|
||||
@ -1570,7 +1570,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@sentry/cli@npm:^2.11.0":
|
||||
"@sentry/cli@npm:^2.13.0":
|
||||
version: 2.13.0
|
||||
resolution: "@sentry/cli@npm:2.13.0"
|
||||
dependencies:
|
||||
@ -1607,7 +1607,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@sentry/tracing@npm:^7.31.1":
|
||||
"@sentry/tracing@npm:^7.38.0":
|
||||
version: 7.38.0
|
||||
resolution: "@sentry/tracing@npm:7.38.0"
|
||||
dependencies:
|
||||
@ -3534,10 +3534,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"core-js@npm:3.27.2":
|
||||
version: 3.27.2
|
||||
resolution: "core-js@npm:3.27.2"
|
||||
checksum: 718debd426f55a6b97cf9b757c936be258afd6d4f7052f89d0f96c982d7013e9000b0b006df42831a0cf32adad298e34d6a19052dce9ae1c7ab87162c0c665e0
|
||||
"core-js@npm:3.28.0":
|
||||
version: 3.28.0
|
||||
resolution: "core-js@npm:3.28.0"
|
||||
checksum: 3155fd0ec16d0089106b145e9595280a4ea4bde0d7ff26aa14364cd4f1c203baf6620c3025acd284f363d08b9f21104101692766ca9a36ffeee7307bdf3e1881
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -4330,7 +4330,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"esbuild@npm:^0.17.4":
|
||||
"esbuild@npm:^0.17.10":
|
||||
version: 0.17.10
|
||||
resolution: "esbuild@npm:0.17.10"
|
||||
dependencies:
|
||||
@ -7888,7 +7888,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prettier@npm:^2.8.3":
|
||||
"prettier@npm:^2.8.4":
|
||||
version: 2.8.4
|
||||
resolution: "prettier@npm:2.8.4"
|
||||
bin:
|
||||
@ -8772,7 +8772,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"sass@npm:^1.57.1":
|
||||
"sass@npm:^1.58.3":
|
||||
version: 1.58.3
|
||||
resolution: "sass@npm:1.58.3"
|
||||
dependencies:
|
||||
@ -9648,7 +9648,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"svelte-check@npm:^3.0.2":
|
||||
"svelte-check@npm:^3.0.3":
|
||||
version: 3.0.3
|
||||
resolution: "svelte-check@npm:3.0.3"
|
||||
dependencies:
|
||||
@ -9876,20 +9876,20 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "tibi-docs@workspace:."
|
||||
dependencies:
|
||||
"@babel/cli": ^7.20.7
|
||||
"@babel/core": ^7.20.12
|
||||
"@babel/cli": ^7.21.0
|
||||
"@babel/core": ^7.21.0
|
||||
"@babel/preset-env": ^7.20.2
|
||||
"@sentry/browser": ^7.31.1
|
||||
"@sentry/cli": ^2.11.0
|
||||
"@sentry/tracing": ^7.31.1
|
||||
"@sentry/browser": ^7.38.0
|
||||
"@sentry/cli": ^2.13.0
|
||||
"@sentry/tracing": ^7.38.0
|
||||
"@tsconfig/svelte": ^3.0.0
|
||||
"@types/lodash": ^4.14.191
|
||||
browser-sync: ^2.27.11
|
||||
chokidar: ^3.5.3
|
||||
connect-history-api-fallback: ^2.0.0
|
||||
core-js: 3.27.2
|
||||
core-js: 3.28.0
|
||||
docpress: ^0.8.2
|
||||
esbuild: ^0.17.4
|
||||
esbuild: ^0.17.10
|
||||
esbuild-svelte: ^0.7.3
|
||||
http-proxy-middleware: ^2.0.6
|
||||
less: ^4.1.3
|
||||
@ -9897,17 +9897,17 @@ __metadata:
|
||||
morgan: ^1.10.0
|
||||
node-fetch: ^3.3.0
|
||||
postcss: ^8.4.21
|
||||
prettier: ^2.8.3
|
||||
prettier: ^2.8.4
|
||||
prettier-plugin-svelte: ^2.9.0
|
||||
sass: ^1.57.1
|
||||
sass: ^1.58.3
|
||||
svelte: ^3.55.1
|
||||
svelte-check: ^3.0.2
|
||||
svelte-check: ^3.0.3
|
||||
svelte-hmr: ^0.15.1
|
||||
svelte-preprocess: ^5.0.1
|
||||
svelte-preprocess-esbuild: ^3.0.1
|
||||
svelte-routing: ^1.6.0
|
||||
tslib: ^2.4.1
|
||||
typescript: ^4.9.4
|
||||
tslib: ^2.5.0
|
||||
typescript: ^4.9.5
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@ -10067,7 +10067,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tslib@npm:^2.0.3, tslib@npm:^2.3.0, tslib@npm:^2.4.1":
|
||||
"tslib@npm:^2.0.3, tslib@npm:^2.3.0, tslib@npm:^2.5.0":
|
||||
version: 2.5.0
|
||||
resolution: "tslib@npm:2.5.0"
|
||||
checksum: ae3ed5f9ce29932d049908ebfdf21b3a003a85653a9a140d614da6b767a93ef94f460e52c3d787f0e4f383546981713f165037dc2274df212ea9f8a4541004e1
|
||||
@ -10095,7 +10095,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@npm:^4.6.2, typescript@npm:^4.9.4":
|
||||
"typescript@npm:^4.6.2, typescript@npm:^4.9.4, typescript@npm:^4.9.5":
|
||||
version: 4.9.5
|
||||
resolution: "typescript@npm:4.9.5"
|
||||
bin:
|
||||
@ -10105,7 +10105,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"typescript@patch:typescript@^4.6.2#~builtin<compat/typescript>, typescript@patch:typescript@^4.9.4#~builtin<compat/typescript>":
|
||||
"typescript@patch:typescript@^4.6.2#~builtin<compat/typescript>, typescript@patch:typescript@^4.9.4#~builtin<compat/typescript>, typescript@patch:typescript@^4.9.5#~builtin<compat/typescript>":
|
||||
version: 4.9.5
|
||||
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=701156"
|
||||
bin:
|
||||
|
Loading…
Reference in New Issue
Block a user