Git Product home page Git Product logo

catharsis's People

Contributors

francoisfrisch avatar hegemonic avatar mbrukman avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

catharsis's Issues

Add performance tests

It'd be nice to have some performance tests, mostly to prevent significant performance regressions but also because people like benchmarks.

Strip newlines from type expressions

Catharsis currently fails to parse type expressions that contain newline characters.

The fix is easy: Strip newlines before handing them off to the parser.

Support quoted strings in JSDoc mode

When JSDoc support is enabled, Catharsis should support type expressions like "foo.bar" and 'foo.bar'. These should be treated as name expressions.

JQuery dependency vulnerability.

Ran a Retire.JS scan and it picked out a vulnerability with the version of Jquery that you're using in this module. Would be nice to get it upgraded.

catharsis\node_modules\underscore-contrib\test\vendor\jquery.js
โ†ณ jquery 1.7.2 has known vulnerabilities: severity: medium; bug: 11290, summary: Selector interpreted as HTML; http://bugs.jquery.com/ticket/11290 http://research.insecurelabs.org/jquery/test/ severity: medium; issue: 2432, summary: 3rd party CORS request may execute; jquery/jquery#2432 http://blog.jquery.com/2016/01/08/jquery-2-2-and-1-12-released/

In JSDoc mode, allow open/close parentheses in name expressions

JSDoc supports a @variation tag, which allows you to distinguish between two symbols with the same longname. For example, you might have a Widget namespace and a Widget class; by adding @variation 2 to the class, you can refer to it as {Widget(2)}.

Catharsis needs to allow this when JSDoc support is enabled.

Allow type applications without a period, even if JSDoc mode is not enabled

Closure Compiler now allows type applications that do not contain a period (for example, Array<string> instead of Array.<string>), and it omits the period when converting a type application to a string. See google/closure-compiler#640.

Catharsis currently requires the period unless JSDoc mode is enabled, and it includes the period when converting a type application to a string. Catharsis should be updated to match Closure Compiler.

Allow function types to be wrapped in parentheses

In some type unions, you need to enclose function types in parentheses to disambiguate the return value (for example, (function(string): boolean)|undefined. We should support this pattern in Catharsis, at least for functions with return values.

Remove `util` dependency in parser

It's a bit silly to do all those checks for process.nextTick and setTimeout, then blindly assume we have access to a Node.js module...

Provide an option to escape non-HTML-safe characters in stringified types

JSDoc needs to be able to stringify bogus type expressions that contain HTML markup, such as:

{
  "type": "TypeApplication",
  "expression": {
    "type": "NameExpression",
    "name": "Array"
  },
  "applications": [
    {
      "type": "NameExpression",
      "name": "<a href=\"FooClass.html\">FooClass</a>"
    }
  ]
}

Without the HTML, that would be stringified as Array.<FooClass>, and I could replace the < with &lt;. With the HTML, though, I need Catharsis to escape the <; otherwise I'll end up escaping the HTML tags as well.

Add a lenient mode

Before I can integrate Catharsis into JSDoc, the parser needs to support a lenient mode that's a little more forgiving than Closure Compiler.

When in lenient mode, the parser should support the following patterns, which have worked in JSDoc 3 for a while:

  • Allow function without trailing parens.
  • Allow type applications without a period (for example, Array<string>).
  • Allow type unions without parens (for example, string|boolean).
  • Allow name expressions to contain # and ~, which JSDoc uses to indicate scope. (I think this should only be allowed in lenient mode, although I'm not certain...)

Also, we should maintain separate type caches for lenient-mode and strict-mode parsing.

Improve the parser's error messages

The parser generated by PEG.js does not provide especially helpful error messages when parsing fails. For example, if you try to parse the type expression Array<string> (should be Array.<string>), the parser throws an exception containing this message:

"$",".",".<","=","\\","\u200C","\u200D","_",Unicode combining mark,Unicode decimal number,Unicode letter number,Unicode lowercase letter,Unicode modifier letter,Unicode other letter,Unicode punctuation connector,Unicode titlecase letter,Unicode uppercase letter

I need to investigate how/whether I can provide better feedback on parse failure.

Allow property names with special characters

If you parse a name expression whose name contains special characters (for example, chat."#channel".open), Catharsis throws an error, even though this namepath is perfectly legal.

Need to investigate which characters are legal in property names and make sure we allow all of them.

This issue blocks jsdoc/jsdoc#395.

Correctly describe `Promise.<string>`

When describing types, we currently assume that all type applications with a single application are arrays. We should instead use the name of the type expression in this case.

Need a stringify method

Catharsis needs a way to stringify the parse results back into a Closure Compiler type string. This method should optionally validate the resulting type string by trying to parse it again.

Handle nullable types in a type union with missing parentheses

Apparently Catharsis can't deal with nullable values in a type union with missing parentheses. For example, !DoubleRect | !Vector | number results in an error, while DoubleRect | Vector | number and (!DoubleRect | !Vector | number) both work fine.

The missing parentheses are not to spec, but it should be possible to update the grammar so it applies the ! to whatever comes before the next | separator.

This came up on the JSDoc mailing list.

Use an LRU cache

For efficiency, Catharsis caches all of its parse results. Right now it caches all parse results indefinitely, which is not appropriate for a long-running process. Catharsis should use an LRU cache instead.

Postfix nullable type operator should be available

I think a postfix nullable type operator should be available, because the closure compiler can parse this.

In a library was provided Google, there are many postfix nullable type operators.

/**
 * Sets the parent of this event target to use for bubbling.
 *
 * @param {goog.events.EventTarget?} parent Parent EventTarget (null if none).
 */
goog.events.EventTarget.prototype.setParentEventTarget = function(parent) {
  this.parentEventTarget_ = parent;
};

But, where is an official Closure Compiler type expression specifications...? I have never seen the specifications. The official document is too insufficient.

What's the correct way to annotate arrays of objects?

I found this on stack overflow, but it doesn't work:

  * @param {{name:string, email:string}[]} users

I tried this, and it works:

* @param {Array<{name:String, email:String}>} users

it returns this in applications:

{
  "type": "RecordType",
  "fields": [
    {
      "type": "FieldType",
      "key": {
        "type": "NameExpression",
        "name": "name:String"
      }
    },
    {
      "type": "FieldType",
      "key": {
        "type": "NameExpression",
        "name": "email:String"
      }
    }
}

Is that the recommended way to document nested objects? Or is there something that would further parse the email/string and name/string combinations into their own properties?

EDIT: this stackoverflow answer suggests doing it like this:

* @param {Object[]} users
* @param {string} users[].name - user name
* @param {string} users[].email - user email

Thanks!

Can't parse the type expression `integer`

Trying to parse the type expression integer results in the following exception:

Expected "!", "(", "*", "...", "?", "function", "null", "undefined" or "{" but "i" found.

WTF, Catharsis.

Can't parse type expressions that contain the identifier 'undefinedFoo'

Originally reported as jsdoc/jsdoc#619:

It looks like the parser is being a bit greedy with the undefined literal. I'm getting an error parsing the following comment.

/**
 * @typedef {{className: (string|undefined),
 *     coordinateFormat: (ol.CoordinateFormatType|undefined),
 *     projection: ol.proj.ProjectionLike,
 *     target: (Element|undefined),
 *     undefinedHTML: (string|undefined)}}
 */

Here's the error message:

Invalid type expression "{className: (string|undefined),
   coordinateFormat: (ol.CoordinateFormatType|undefined),
   projection: ol.proj.ProjectionLike,
   target: (Element|undefined),
   undefinedHTML: (string|undefined)}": Expected "!", ",", ":", "=", "?", "|" or "}" but "H" found.

I'm having trouble debugging this. It may be an issue with Catharsis or PEG.js. Thanks for any insight.

Support Jsdoc Toolkit 2-style nested arrays

Catharsis currently fails to parse type expressions like string[][] (equivalent to Array.<Array.<string>>). We should support this form of nested type application when JSDoc support is enabled.

are function params available when using a @typedef?

I'm trying to parse a typedef such as:

@typedef {function((ol.Coordinate|undefined)): string}

which is part of:

/**
 * A function that formats a {@link ol.Coordinate} into a string.
 * @typedef {function((ol.Coordinate|undefined)): string}
 * @todo stability experimental
 */
ol.CoordinateFormatType;

but it seems the function param types and the return type are not available in the JSDoc doclet?

Am I missing something here? Or is this not supported?

implementation question

I'm working on a tool that might use jsdoctypeparser but I just noticed this library and saw that it's similar but seems to lean towards closure compiler (is that correct? I'm still getting familiarized with the different specs).

Do you have a recommendation between this and jsdoctypeparser. Will catharsis be used in jsdoc? (just trying to decide which one I should focus on implementing). Thanks!

edit: also, in the returned object, does variable mean "variadic" (e.g. variable number of arguments)? I reviewed the docs and didn't see it (sorry if I missed it).

Rewrite Catharsis as a Pratt parser

(Disclaimer: I'll probably never actually do this.)

Catharsis's parser is currently generated by PEG.js from a parsing expression grammar. That seemed like a good choice when I made it. Over time, though, as I've implemented more and more undocumented things that Closure Compiler supports, the grammar has become quite brittle and difficult to change.

In the unlikely event that I'm ever so inclined, it would be interesting to try to reimplement Catharsis as a Pratt parser, which should be more flexible while still being reasonably straightforward to implement by hand.

Support alternate syntax for identifiers/repeatable function params (JSDoc only)

When JSDoc support is enabled, we need to allow repeatable function params to omit the square brackets around the param. We also need to allow identifiers to include function signature-like things.

For example, MyClass(...foo) and function(...string) should be allowed only when JSDoc support is enabled; function(...[string]) should always be allowed.

Allow hyphens in the IdentifierName

In CommonJS module names it is common to use hyphens.
It is therefore possible for an object to includes a hyphen in the type expression.

Passing module:montage/core/event/event-manager.EventManager to catharsis.parse throws a SyntaxError since the IdentifierName doesn't allow hyphens.

The reason parser doesn't allow hyphens is for numeric value support. I think that we could safely support hyphens in the IdentifierName since I can see no reason to support numeric values in the IdentifierName.

The ticket that describes the usage where this issue is found is here, jsdoc/jsdoc#369

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.