Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atomdoc

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomdoc - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

34

lib/parser.js
(function() {
var ArgumentListItemRegex, Doc, ReturnsRegex, SpecialHeadingDepth, SpecialHeadings, VisibilityRegex, generateBlockquote, generateCode, generateDescription, generateHeading, generateList, generateParagraph, getLinkMatch, isArgumentListItem, isAtArgumentList, isReturnValue, marked, multiplyString, parse, parseArgumentList, parseArgumentsSection, parseEventsSection, parseExamplesSection, parseListItem, parseReturnValues, parseSummaryAndDescription, stopOnSectionBoundaries, _, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
var ArgumentListItemRegex, Doc, ReturnsRegex, SpecialHeadingDepth, SpecialHeadings, VisibilityRegex, generateBlockquote, generateCode, generateDescription, generateHeading, generateList, generateParagraph, getLinkMatch, isArgumentListItem, isAtArgumentList, isReturnValue, marked, multiplyString, parse, parseArgumentList, parseArgumentsSection, parseEventsSection, parseExamplesSection, parseListItem, parseReturnValues, parseSummaryAndDescription, parseTitledArgumentsSection, stopOnSectionBoundaries, _, _ref;

@@ -15,3 +14,3 @@ _ = require('underscore');

SpecialHeadings = ['Arguments', 'Events', 'Examples'];
SpecialHeadings = '^Arguments|Events|Examples';

@@ -32,3 +31,3 @@ VisibilityRegex = '^\\s*([a-zA-Z]+):\\s*';

parse = function(docString) {
var args, doc, events, examples, extraDescription, firstToken, lexer, returnValues, tokens;
var args, doc, events, examples, extraDescription, firstToken, lexer, returnValues, titledArgs, tokens;
lexer = new marked.Lexer();

@@ -43,3 +42,8 @@ tokens = lexer.lex(docString);

while (tokens.length) {
if (args = parseArgumentsSection(tokens)) {
if (titledArgs = parseTitledArgumentsSection(tokens)) {
if (doc.titledArguments == null) {
doc.titledArguments = [];
}
doc.titledArguments.push(titledArgs);
} else if (args = parseArgumentsSection(tokens)) {
doc["arguments"] = args;

@@ -124,2 +128,18 @@ } else if (events = parseEventsSection(tokens)) {

parseTitledArgumentsSection = function(tokens) {
var firstToken;
firstToken = _.first(tokens);
if (!(firstToken && firstToken.type === 'heading')) {
return;
}
if (!(firstToken.text.indexOf('Arguments:') === 0 && firstToken.depth === SpecialHeadingDepth)) {
return;
}
return {
title: tokens.shift().text.replace('Arguments:', '').trim(),
description: generateDescription(tokens, stopOnSectionBoundaries),
"arguments": parseArgumentList(tokens)
};
};
parseEventsSection = function(tokens) {

@@ -369,3 +389,3 @@ var args, description, eventHeadingDepth, events, firstToken, name, stopTokenCallback, summary, visibility, _ref1;

stopOnSectionBoundaries = function(token, tokens) {
var listToken, _i, _len, _ref1, _ref2;
var listToken, _i, _len, _ref1;
if ((_ref1 = token.type) === 'paragraph' || _ref1 === 'text') {

@@ -376,3 +396,3 @@ if (isReturnValue(token.text)) {

} else if (token.type === 'heading') {
if (token.depth === SpecialHeadingDepth && (_ref2 = token.text, __indexOf.call(SpecialHeadings, _ref2) >= 0)) {
if (token.depth === SpecialHeadingDepth && new RegExp(SpecialHeadings).test(token.text)) {
return false;

@@ -379,0 +399,0 @@ }

{
"name": "atomdoc",
"version": "1.0.3",
"version": "1.0.4",
"description": "A atomdoc parser",

@@ -5,0 +5,0 @@ "main": "./lib/atomdoc.js",

@@ -9,3 +9,3 @@ # AtomDoc parser

It's on [npm](https://www.npmjs.org/package/atomdoc)
It's on [npm](https://www.npmjs.org/package/atomdoc).

@@ -179,5 +179,5 @@ ```

The parser uses [marked]'s lexer.
The parser uses [marked][marked]'s lexer.
[marked]:https://github.com/chjj/marked
[marked]: https://github.com/chjj/marked
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc