{"id":19607869,"url":"https://github.com/mkdoc/mkparse","last_synced_at":"2025-04-27T20:32:28.569Z","repository":{"id":57298932,"uuid":"52677707","full_name":"mkdoc/mkparse","owner":"mkdoc","description":"Fast, streaming and configurable comment parser","archived":true,"fork":false,"pushed_at":"2017-01-03T03:00:11.000Z","size":317,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T10:09:49.501Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkdoc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-27T17:02:52.000Z","updated_at":"2024-12-11T22:13:08.000Z","dependencies_parsed_at":"2022-08-26T18:12:41.183Z","dependency_job_id":null,"html_url":"https://github.com/mkdoc/mkparse","commit_stats":null,"previous_names":["tmpfs/cparse"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdoc%2Fmkparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdoc%2Fmkparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdoc%2Fmkparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdoc%2Fmkparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkdoc","download_url":"https://codeload.github.com/mkdoc/mkparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251204564,"owners_count":21552239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T10:12:44.671Z","updated_at":"2025-04-27T20:32:27.606Z","avatar_url":"https://github.com/mkdoc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Comment Parser\n\n[![Build Status](https://travis-ci.org/mkdoc/mkparse.svg?v=3)](https://travis-ci.org/mkdoc/mkparse)\n[![npm version](http://img.shields.io/npm/v/mkparse.svg?v=3)](https://npmjs.org/package/mkparse)\n[![Coverage Status](https://coveralls.io/repos/mkdoc/mkparse/badge.svg?branch=master\u0026service=github\u0026v=3)](https://coveralls.io/github/mkdoc/mkparse?branch=master)\n\n\u003e Parse source file comments\n\nFast, streaming and configurable comment parser; currently supports 30+ languages.\n\nDesigned for polyglot programmers to:\n\n* Combine comments from various files (HTML, CSS and Javascript for example)\n* Parse comments from any language\n* Strip comments from any file\n* Separate comments into another file\n* Implement custom tag systems (annotations)\n* Operate on processing instructions (see the [pi language](https://github.com/mkdoc/mkparse/blob/master/API.md#pi))\n* Document JSON files, read comments then strip in build process\n\nSee the [i/o sample](https://github.com/mkdoc/mkparse/blob/master/EXAMPLE.md) and the [api docs](https://github.com/mkdoc/mkparse/blob/master/API.md).\n\n## Install\n\n```\nnpm i mkparse --save\n```\n\nFor the command line interface install [mkdoc][] globally (`npm i -g mkdoc`).\n\n---\n\n- [Install](#install)\n- [Usage](#usage)\n- [Example](#example)\n- [Comments](#comments)\n  - [Tags](#tags)\n  - [Block](#block)\n- [Help](#help)\n- [License](#license)\n\n---\n\n## Usage\n\nParse a string or buffer:\n\n```javascript\nvar mkparse = require('mkparse')\n  , stream = mkparse.parse('/**Compact comment*/');\nstream.on('comment', function(comment) {\n  console.dir(comment);\n});\n```\n\nLoad and parse file contents:\n\n```javascript\nvar mkparse = require('mkparse')\n  , stream = mkparse.load('index.js');\nstream.on('comment', function(comment) {\n  console.dir(comment);\n});\n```\n\nParse and write comment data to file as newline delimited JSON:\n\n```javascript\nvar mkparse = require('mkparse')\n  , fs = require('fs')\n  , stream = mkparse.load('index.js').stringify();\nstream.pipe(fs.createWriteStream('index-ast.json.log'));\n```\n\nUse a language pack:\n\n```javascript\nvar mkparse = require('mkparse')\n  , stream = mkparse.parse(\n      '# @file spec.rb', {rules: require('mkparse/lang/ruby')});\nstream.on('comment', function(comment) {\n  console.dir(comment);\n});\n```\n\nCombine language pack rules:\n\n```javascript\nvar mkparse = require('mkparse')\n  , stream = mkparse.parse(\n      '; ini style comment\\n# shell style comment',\n      {rules: [require('mkparse/lang/ini'), require('mkparse/lang/shell')]});\nstream.on('comment', function(comment) {\n  console.dir(comment);\n});\n```\n\nFor more detail see the [api docs](https://github.com/mkdoc/mkparse/blob/master/API.md).\n\n## Example\n\nPrint comments in a file:\n\n```shell\nmkparse index.js\n```\n\nPrint as json:\n\n```shell\nmkparse lib/*.js -j\n```\n\nPrint the source content without comments:\n\n```shell\nmkparse index.js -s\n```\n\n## Comments\n\nA comment consists of a multi-line description and optional tag annotations:\n\n```javascript\n/**\n * Method description\n * that can span multiple lines.\n *\n * @name method\n */\n\n// Method description\n// that can span multiple lines.\n//\n// @name method\n```\n\nAll the following comments resolve to the same description with the default settings:\n\n```javascript\n/** Comment description */\n\n/**\n * Comment description\n */\n\n/*************************\n * Comment description   *\n ************************/\n\n// Comment description //\n\n//\n// Comment description\n//\n```\n\n### Tags\n\nTags allow annotating a comment with meaningful information to consumers of the comment data.\n\nThe tag parser recognises tags beginning with an `@` and is able to parse `type`,\n`value` (default), `name`, `description` and an `optional` flag.\n\nGrammar for the default tag parser:\n\n```\n@id {type=value} [name] description\n```\n\nAll fields but the tag `id` are considered optional, to set the `optional` flag\nenclose `name` in square brackets (`[]`).\n\nWhen given `@property {String=mkdoc} [nickname] user` it expands to a tag object such as:\n\n```javascript\n{\n  id: 'property',\n  type: 'String',\n  value: 'mkdoc',\n  name: 'nickname',\n  description: 'user',\n  optional: true\n}\n```\n\nSee the [tag api docs](https://github.com/mkdoc/mkparse/blob/master/API.md#tag) to change the tag parsing.\n\n### Block\n\nBy default continuous single-line comments are gathered into a single `comment` object. The\nrule is that if the next line does not match whitespace followed by the start of a\nsingle-line comment then the block is terminated.\n\nNote that inline comments also break the block:\n\n```javascript\n// \n// Comment description\n// \nvar foo; // Separate inline comment\n```\n\nWill result in two comments, whilst:\n\n```javascript\n// Comment description\n// \n// More information.\n```\n\nResults in a single comment.\n\n## Help\n\n```\nUsage: mkparse [options] \u003cfiles...\u003e\n\n  Parse source file comments.\n\nOptions\n  -l, --lang=[LANG]       Set language for all files\n  -s, --strip             Print content only, remove comments\n  -c, --content           Include non-comment content\n  -d, --dotted            Parse dotted names\n  -j, --json              Print comments as JSON\n  -i, --indent=[NUM]      Number of spaces for JSON (default: 0)\n  -h, --help              Display help and exit\n  --version               Print the version and exit\n\nmkparse@1.5.9\n```\n\n## License\n\nMIT\n\n---\n\nCreated by [mkdoc](https://github.com/mkdoc/mkdoc) on April 18, 2016\n\n[mkdoc]: https://github.com/mkdoc/mkdoc\n[jshint]: http://jshint.com\n[jscs]: http://jscs.info\n[mdp]: https://github.com/tmpfs/mdp\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkdoc%2Fmkparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkdoc%2Fmkparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkdoc%2Fmkparse/lists"}