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

Function USAGE

packages/analytics-cli/src/commands/docs.js:49–76  ·  view source on GitHub ↗
(content, options, context)

Source from the content-addressed store, hash-verified

47 return updatedContent.replace(/^\s+|\s+$/g, '')
48 },
49 USAGE(content, options, context) {
50 let updatedContent = ''
51 const opts = options || {}
52 const basePath = path.dirname(context.originalPath)
53 const browserPath = opts.browser || path.join(basePath, 'src/browser.js')
54 const nodePath = opts.node || path.join(basePath, 'src/node.js')
55 const packageJson = fs.readFileSync(path.join(basePath, 'package.json'), 'utf-8')
56 const pkg = JSON.parse(packageJson)
57
58 if (browserPath && fs.existsSync(browserPath)) {
59 const fileContents = fs.readFileSync(browserPath, 'utf-8')
60 const docBlocs = dox.parseComments(fileContents, { raw: true, skipSingleStar: true })
61
62 docBlocs.forEach((data) => {
63 const example = data.tags.filter((tag) => {
64 return tag.type === 'example'
65 }).map((tag) => {
66 return tag.string
67 })
68 if (example && example[0]) {
69 updatedContent += renderUsageExample(example[0], data.ctx.name, pkg.name)
70 updatedContent += `\n`
71 }
72 })
73 }
74
75 return updatedContent.replace(/^\s+|\s+$/g, '')
76 },
77 METHODZ(content, options, context) {
78 let updatedContent = ''
79 const opts = options || {}

Callers

nothing calls this directly

Calls 1

renderUsageExampleFunction · 0.85

Tested by

no test coverage detected