{"name":"jest-docblock","version":"0.0.0","_id":"jest-docblock@0.0.0","maintainers":[{"name":"cpojer","email":"christoph.pojer@gmail.com"}],"dist":{"shasum":"cf51e191d00ae5f8a62e61cd326bd0493e9f6a26","tarball":"http://registry-npm.ywwl.com/jest-docblock/download/jest-docblock-0.0.0.tgz","integrity":"sha512-uvVsUe8G8cGOXpxBi6XU1DhWmw2FdRrdgpvF+AwvUJ0WQ7HakgSDuSpuoUcGcc6dh2yx1ZngFGQpM3VUJl93lg==","signatures":[{"sig":"MEYCIQC8gOnQM2VP0qXnxwjFzk+U3TyNcITG9utzwwJirXXKdgIhAOO0YQMp/G8Fp505PUwmf0T90lj3k4hEe5XxLZsRXPvd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":413,"noattachment":false,"key":"/jest-docblock/-/jest-docblock-0.0.0.tgz"},"_from":".","_shasum":"cf51e191d00ae5f8a62e61cd326bd0493e9f6a26","scripts":{},"_npmUser":{"name":"cpojer","email":"christoph.pojer@gmail.com"},"_npmVersion":"4.1.2","directories":{},"_nodeVersion":"7.7.1","_npmOperationalInternal":{"tmp":"tmp/jest-docblock-0.0.0.tgz_1488553847307_0.10164580773562193","host":"packages-18-east.internal.npmjs.com"},"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":1488553847875,"_cnpm_publish_time":1488553847875,"dist-tags":{"latest":"30.5.0","next":"30.0.0-rc.1"}}