{"name":"jest-docblock","version":"29.7.0","license":"MIT","_id":"jest-docblock@29.7.0","maintainers":[{"name":"scotthovestadt","email":"scott.hovestadt@gmail.com"},{"name":"rubennorte","email":"rubennorte@gmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"fb","email":"opensource+npm@fb.com"},{"name":"aaronabramov","email":"aaron@abramov.io"},{"name":"davidzilburg","email":"davidzilburg@gmail.com"}],"homepage":"https://github.com/jestjs/jest#readme","bugs":{"url":"https://github.com/jestjs/jest/issues"},"dist":{"shasum":"8fddb6adc3cdc955c93e2a87f61cfd350d5d119a","tarball":"http://registry-npm.ywwl.com/jest-docblock/download/jest-docblock-29.7.0.tgz","fileCount":5,"integrity":"sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==","signatures":[{"sig":"MEUCIGKVuQ7Vr56Vrcx4nvq4+bjfG6yalAjc4I752aPoAY67AiEAw9zgX/18ExmuIxEsWAwUrbcaPlxK1Ts+6aka6ZnNQrQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8989,"size":3565,"noattachment":false,"key":"/jest-docblock/-/jest-docblock-29.7.0.tgz"},"main":"./build/index.js","types":"./build/index.d.ts","engines":{"node":"^14.15.0 || ^16.10.0 || >=18.0.0"},"exports":{".":{"types":"./build/index.d.ts","default":"./build/index.js"},"./package.json":"./package.json"},"gitHead":"4e56991693da7cd4c3730dc3579a1dd1403ee630","_npmUser":{"name":"simenb","email":"sbekkhus91@gmail.com"},"repository":{"url":"git+https://github.com/jestjs/jest.git","type":"git","directory":"packages/jest-docblock"},"_npmVersion":"lerna/1.13.0/node@v18.17.1+arm64 (darwin)","description":"`jest-docblock` is a package that can extract and parse a specially-formatted comment called a \"docblock\" at the top of a file.","directories":{},"_nodeVersion":"18.17.1","dependencies":{"detect-newline":"^3.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"*"},"_npmOperationalInternal":{"tmp":"tmp/jest-docblock_29.7.0_1694501019432_0.3851613349343064","host":"s3://npm-registry-packages"},"readme":"# jest-docblock\n\n`jest-docblock` is a package that can extract and parse a specially-formatted comment called a \"docblock\" at the top of a file.\n\nA docblock looks like this:\n\n```js\n/**\n * Stuff goes here!\n */\n```\n\nDocblocks can contain pragmas, which are words prefixed by `@`:\n\n```js\n/**\n * Pragma incoming!\n *\n * @flow\n */\n```\n\nPragmas can also take arguments:\n\n```js\n/**\n * Check this out:\n *\n * @myPragma it is so cool\n */\n```\n\n`jest-docblock` can:\n\n- extract the docblock from some code as a string\n- parse a docblock string's pragmas into an object\n- print an object and some comments back to a string\n\n## Installation\n\n```sh\n# with yarn\n$ yarn add jest-docblock\n# with npm\n$ npm install jest-docblock\n```\n\n## Usage\n\n```js\nconst code = `\n/**\n * Everything is awesome!\n *\n * @everything is:awesome\n * @flow\n */\n\n export const everything = Object.create(null);\n export default function isAwesome(something) {\n   return something === everything;\n }\n`;\n\nconst {\n  extract,\n  strip,\n  parse,\n  parseWithComments,\n  print,\n} = require('jest-docblock');\n\nconst docblock = extract(code);\nconsole.log(docblock); // \"/**\\n * Everything is awesome!\\n * \\n * @everything is:awesome\\n * @flow\\n */\"\n\nconst stripped = strip(code);\nconsole.log(stripped); // \"export const everything = Object.create(null);\\n export default function isAwesome(something) {\\n return something === everything;\\n }\"\n\nconst pragmas = parse(docblock);\nconsole.log(pragmas); // { everything: \"is:awesome\", flow: \"\" }\n\nconst parsed = parseWithComments(docblock);\nconsole.log(parsed); // { comments: \"Everything is awesome!\", pragmas: { everything: \"is:awesome\", flow: \"\" } }\n\nconsole.log(print({pragmas, comments: 'hi!'})); // /**\\n * hi!\\n *\\n * @everything is:awesome\\n * @flow\\n */;\n```\n\n## API Documentation\n\n### `extract(contents: string): string`\n\nExtracts a docblock from some file contents. Returns the docblock contained in `contents`. If `contents` did not contain a docblock, it will return the empty string (`\"\"`).\n\n### `strip(contents: string): string`\n\nStrips the top docblock from a file and return the result. If a file does not have a docblock at the top, then return the file unchanged.\n\n### `parse(docblock: string): {[key: string]: string | string[] }`\n\nParses the pragmas in a docblock string into an object whose keys are the pragma tags and whose values are the arguments to those pragmas.\n\n### `parseWithComments(docblock: string): { comments: string, pragmas: {[key: string]: string | string[]} }`\n\nSimilar to `parse` except this method also returns the comments from the docblock. Useful when used with `print()`.\n\n### `print({ comments?: string, pragmas?: {[key: string]: string | string[]} }): string`\n\nPrints an object of key-value pairs back into a docblock. If `comments` are provided, they will be positioned on the top of the docblock.\n","publish_time":1694501019655,"_cnpm_publish_time":1694501019655,"dist-tags":{"latest":"30.5.0","next":"30.0.0-rc.1"}}