MCPcopy
hub / github.com/docsifyjs/docsify / docsifyInit

Function docsifyInit

test/helpers/docsify-init.js:36–359  ·  view source on GitHub ↗

* Jest / Playwright helper for creating custom docsify test sites * * @param {Object} options options object * @param {Function|Object} [options.config] docsify configuration (merged with default) * @param {String} [options.html] HTML content to use for docsify `index.html` page * @param {Objec

(options = {})

Source from the content-addressed store, hash-verified

34 * @returns {Promise}
35 */
36async function docsifyInit(options = {}) {
37 const isJSDOM = 'window' in global;
38 const isPlaywright = 'page' in global;
39
40 const defaults = {
41 config: {
42 basePath: process.env.TEST_HOST,
43 el: '#app',
44 },
45 html: `
46 <!DOCTYPE html>
47 <html>
48 <head>
49 <meta charset="UTF-8" />
50 </head>
51 <body>
52 <div id="app"></div>
53 </body>
54 </html>
55 `,
56 markdown: {
57 coverpage: '',
58 homepage: '',
59 navbar: '',
60 sidebar: '',
61 },
62 routes: {},
63 script: '',
64 scriptURLs: [],
65 style: '',
66 styleURLs: [],
67 testURL: `${process.env.TEST_HOST}/docsify-init.html`,
68 waitForSelector: '#main > *',
69 };
70 const settings = {
71 ...defaults,
72 ...options,
73 get config() {
74 const sharedConfig = {
75 ...defaults.config,
76 // Conditionally set options but allow explicit overrides
77 coverpage: Boolean(settings.markdown.coverpage),
78 loadNavbar: Boolean(settings.markdown.navbar),
79 loadSidebar: Boolean(settings.markdown.sidebar),
80 };
81
82 const updateBasePath = config => {
83 if (config.basePath) {
84 config.basePath = new URL(
85 config.basePath,
86 process.env.TEST_HOST
87 ).href;
88 }
89 };
90
91 // Config as function
92 if (typeof options.config === 'function') {
93 return function (vm) {

Callers 14

docs.test.jsFile · 0.85
emoji.test.jsFile · 0.85
docsify.test.jsFile · 0.85
example.test.jsFile · 0.85
render.test.jsFile · 0.85
vue.test.jsFile · 0.85
plugins.test.jsFile · 0.85
security.test.jsFile · 0.85
search.test.jsFile · 0.85
example.test.jsFile · 0.85

Calls 3

waitForSelectorFunction · 0.85
headerMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…