MCPcopy Create free account
hub / github.com/DavidWells/analytics / nodeUsage

Function nodeUsage

scripts/docs.js:614–645  ·  view source on GitHub ↗
(data, pkg)

Source from the content-addressed store, hash-verified

612}
613
614function nodeUsage(data, pkg) {
615 // Find doc block with example (should only be one the main function)
616 const main = data.jsdoc.find((doc) => Boolean(doc.examples))
617
618 const name = main.name
619 const exampleCode = main.examples[0]
620
621 const code = `
622const analyticsLib = require('analytics').default
623const ${name} = require('${pkg.name}').default
624
625const analytics = analyticsLib({
626 app: 'my-app-name',
627 plugins: [
628 ${exampleCode}
629 ]
630})
631
632${renderRelevantMethods(data)}`
633
634 return `<details>
635 <summary>Server-side Node.js with common JS</summary>
636
637 If using node, you will want to import the \`.default\`
638
639 \`\`\`js
640${indentString(formatCode(code), 2)}
641 \`\`\`
642
643</details>
644`
645}
646
647async function browserStandaloneUsage(data, pkg, dir) {
648 const browserFile = path.join(dir, 'dist', `${pkg.name}.js`)

Callers 1

getUsageExamplesFunction · 0.85

Calls 2

renderRelevantMethodsFunction · 0.85
formatCodeFunction · 0.85

Tested by

no test coverage detected