Skip to content

A source code docstring parser for a custom C-like and Python-like format

License

Notifications You must be signed in to change notification settings

6r1d/dst-parser

 
 

Repository files navigation

Docstring Parser

The docstring parser for C-like (including C++, JavaScript, Rust) and Python-like syntax, where code that should be included in documentation is marked with custom comments.

Syntax

A piece of code is considered a named fragment when it is located between // BEGIN FRAGMENT: <name> and // END FRAGMENT, <> not included. This syntax is case-sensitive.

Don't use special characters in names; snakeCase is preferrable.

Fragments can be included in one another. In that case the lines matching // BEGIN FRAGMENT: <name> and // END FRAGMENT are removed.

Elements between // BEGIN ESCAPE and // END ESCAPE are excluded unconditionally from the tutorial.

Installation

Install the parser as a development dependency of your package:

npm install dst-parser --save-dev

Install the parser globally:

npm install dst-parser -g

Example code

import { ExampleParser } from "dst-parser"
let text = `
// BEGIN FRAGMENT: Test
This text is displayed
// BEGIN ESCAPE
OR IS IT?
// END ESCAPE
// END FRAGMENT
`
let parser_inst = new ExampleParser(text)
console.log(parser_inst.mapLines())

About

A source code docstring parser for a custom C-like and Python-like format

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 87.8%
  • Python 5.4%
  • JavaScript 3.1%
  • C 2.2%
  • Rust 1.5%