All Projects → DSSORG → Dss

DSSORG / Dss

Licence: mit
📄 Documented Style Sheets Parser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Dss

Cfmt
cfmt is a tool to wrap Go comments over a certain length to a new line.
Stars: ✭ 28 (-92.53%)
Mutual labels:  static-analysis, comments
Phpmnd
PHP Magic Number Detector
Stars: ✭ 431 (+14.93%)
Mutual labels:  static-analysis, detector
Device Detector Js
A precise user agent parser and device detector written in TypeScript
Stars: ✭ 193 (-48.53%)
Mutual labels:  parser, detector
go-mnd
Magic number detector for Go.
Stars: ✭ 153 (-59.2%)
Mutual labels:  static-analysis, detector
Detect It Easy
Program for determining types of files for Windows, Linux and MacOS.
Stars: ✭ 2,982 (+695.2%)
Mutual labels:  static-analysis, detector
Spoon
Spoon is a metaprogramming library to analyze and transform Java source code (up to Java 15). 🥄 is made with ❤️, 🍻 and ✨. It parses source files to build a well-designed AST with powerful analysis and transformation API.
Stars: ✭ 1,078 (+187.47%)
Mutual labels:  static-analysis, parser
Parse Code Context
Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype properties, prototype methods etc.
Stars: ✭ 7 (-98.13%)
Mutual labels:  comments, parser
Zpa
A parser and source code analyzer for PL/SQL and Oracle SQL.
Stars: ✭ 124 (-66.93%)
Mutual labels:  static-analysis, parser
Php Parser
A PHP parser written in PHP
Stars: ✭ 15,101 (+3926.93%)
Mutual labels:  static-analysis, parser
Tsdoc
A doc comment standard for TypeScript
Stars: ✭ 3,785 (+909.33%)
Mutual labels:  comments, parser
Schemalex
Generate difference sql of two mysql schema
Stars: ✭ 356 (-5.07%)
Mutual labels:  parser
Clang Tools Extra
Mirror kept for legacy. Moved to https://github.com/llvm/llvm-project
Stars: ✭ 358 (-4.53%)
Mutual labels:  static-analysis
Ratel Core
High performance JavaScript to JavaScript compiler with a Rust core
Stars: ✭ 367 (-2.13%)
Mutual labels:  parser
Go Syslog
Blazing fast syslog parser
Stars: ✭ 370 (-1.33%)
Mutual labels:  parser
Go Shellwords
Parse line as shell words
Stars: ✭ 355 (-5.33%)
Mutual labels:  parser
Selectolax
Python binding to Modest engine (fast HTML5 parser with CSS selectors).
Stars: ✭ 368 (-1.87%)
Mutual labels:  parser
Pyhocon
HOCON parser for Python
Stars: ✭ 355 (-5.33%)
Mutual labels:  parser
Hashover Next
This branch will be HashOver 2.0
Stars: ✭ 353 (-5.87%)
Mutual labels:  comments
Detekt
Static code analysis for Kotlin
Stars: ✭ 4,169 (+1011.73%)
Mutual labels:  static-analysis
Anglesharp
👼 The ultimate angle brackets parser library parsing HTML5, MathML, SVG and CSS to construct a DOM based on the official W3C specifications.
Stars: ✭ 4,018 (+971.47%)
Mutual labels:  parser

npm npm License

DSS

DSS, Documented Style Sheets is a comment guide and parser for CSS, LESS, STYLUS, SASS and SCSS code. This project does static file analysis and parsing to generate an object to be used for generating styleguides.

Table of Contents

Parsing a File

In most cases, you will want to include the DSS parser in a build step that will generate documentation files automatically (or you just want to play around with this returned Object for other means); Either way, we officially support a Grunt Plugin and a Gulp Plugin.

Examples

Example Comment Block Format
//
// @name Button
// @description Your standard form button.
// 
// @state :hover - Highlights when hovering.
// @state :disabled - Dims the button when disabled.
// @state .primary - Indicates button is the primary action.
// @state .smaller - A smaller button
// 
// @markup
//   <button>This is a button</button>
// 
Example Usage
// Requirements
var fs = require( 'fs' );
var dss = require( 'dss' );

// Get file contents
var fileContents = fs.readFileSync( 'styles.css' );

// Run the DSS Parser on the file contents
dss.parse( fileContents, {}, function ( parsedObject ) {

  // Output the parsed document
  console.log( parsedObject );

});

Example Output
{
  "name": "Button",
  "description": "Your standard form button.",
  "state": [
    { 
      "name": ":hover",
      "escaped": "pseudo-class-hover",
      "description": "Highlights when hovering."
    },
    {
      "name": ":disabled",
      "escaped": "pseudo-class-disabled",
      "description": "Dims the button when disabled."
    },
    {
      "name": ".primary",
      "escaped": "primary",
      "description": "Indicates button is the primary action."
    },
    {
      "name": ".smaller",
      "escaped": "smaller",
      "description": "A smaller button"
    }
  ],
  "markup": {
    "example": "<button>This is a button</button>",
    "escaped": "&lt;button&gt;This is a button&lt;/button&gt;"
  }
}

dss.detector( callback )

This method defines the way in which points of interest (ie. variables) are found in lines of text and then, later, parsed. DSS dogfoods this API and the default implementation is shown below.

Default Detector:
// Describe default detection pattern
// Note: the current line, as a string, is passed to this function
dss.detector( function( line ) {
  
  if ( typeof line !== 'string' ) {
    return false;
  }
  var reference = line.split( "\n\n" ).pop();
  return !!reference.match( /.*@/ );

});

dss.parser( name, callback )

DSS, by default, includes 4 parsers for the name, description, state and markup of a comment block. You can add to, or override, these defaults by registering a new parser. These defaults also follow a pattern which uses the @ decorator to identify them. You can modify this behaivour providing a different callback function to dss.detector().

dss.parser expects the name of the variable you're looking for and a callback function to manipulate the contents. Whatever is returned by that callback function is what is used in generate JSON.

Callback this:
  • this.file: The current file
  • this.name: The name of the parser
  • this.options: The options that were passed to dss.parse() initially
  • this.line:
    • this.line.contents: The content associated with this variable
    • this.line.from: The line number where this variable was found
    • this.line.to: The line number where this variable's contents ended
  • this.block:
    • this.block.contents: The content associated with this variable's comment block
    • this.block.from: The line number where this variable's comment block starts
    • this.block.to: The line number where this variable's comment block ends
Custom Parser Examples:
// Matches @version
dss.parser( 'version', function () {

  // Just returns the lines contents
  return this.line.contents;

});
dss.parser( 'link', function () {

  // Replace link with HTML wrapped version
  var exp = /(b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
  this.line.contents.replace(exp, "<a href='$1'>$1</a>");
  return line;
   
});

Other Projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].