Leaflet / Leafdoc

A lightweight NaturalDocs-like LeafletJS-style documentation generator
54 stars 19 forks source link

HTML Notation is not parsed correct #57

Open Falke-Design opened 3 years ago

Falke-Design commented 3 years ago

There is a issue https://github.com/Leaflet/Leaflet/pull/6208 where the ' is not correct parsed, the regex have to be changed:

Doc

@option zoomOutText: String = '−'

Regex:

\s*(?:)@(?:)((?:)\S+)(?:)(?:\s+(?:)((?:)[^;\n]+)){0,1}

When the ; is removed it works.

I tried do change it and select until the exact match ;\n with or without ; but the regex is to complicated for me.

IvanSanchez commented 3 years ago

I'm not seeing that regexp in src/regexps.mjs. Are you sure that's the regexp being used?

IvanSanchez commented 3 years ago

It might be autogenerated from

    global.leafDirective = xRegExp(`  \\s* ${  char  } (?<directive> \\S+ ) (\\s+ (?<content> [^;\\n]+ )){0,1} `, 'gnx');

It might be possible to trick the regexp by adding another ; at the end, i.e.

@option zoomOutText: String = '&#x2212;';
Falke-Design commented 3 years ago

Yes sorry, it is autogenerated from there.

No your suggestion is not working,

It is working with the regex:

\s*(?:)@(?:)((?:)\S+)(?:)(?:\s+(?:)((?:).+[^;\n])){0,1}

I removed the + from the end added it before the negation [^;\n]

So it looks like:

global.leafDirective = xRegExp(`  \\s* ${  char  } (?<directive> \\S+ ) (\\s+ (?<content> .+[^;\\n])){0,1} `, 'gnx');

@IvanSanchez maybe you can test the regex on you projects, because the test suite are not working for me.

If it is working for you I will create a PR

IvanSanchez commented 3 years ago

@Falke-Design It seems that I messed up the unit tests after tweaking the basic template a bit yesterday. Mea culpa.

Anyway, I tested your regexp, and unfortunately it breaks stuff, specifically:

    # 🍂property parent: TreeNode; Parent of this node.  Will be `nil` for a root node.
181,182c181,182
<               <td><code><a href='#treenode'>TreeNode</a></code></td>
<               <td>Parent of this node.  Will be <code>nil</code> for a root node.</td>
---
>               <td><code>TreeNode; Parent of this node.  Will be `nil` for a root node.</code></td>
>               <td></td>

That shorthand syntax (which is equivalent to writing two lines, one with the actual directive and another with the text) is used elsewhere, e.g. https://github.com/Leaflet/Leaflet/blob/7db94fd1ec23f0967dd8b07a5e2e2b1554b6d8db/src/layer/vector/Circle.js#L39

IvanSanchez commented 3 years ago

@Falke-Design Can you please try with the code from 5e4cdf9276d0e44f55f0848a8481fc4050f4e51c ? That regexp should behave nicer (now stuff needs ;, space after a semicolon, to separate several directives in the same line).

It'd be nice to have a specific e2e test with the zoomControl stuff afterwards.

Falke-Design commented 3 years ago

I would like to create tests but it is hard for me to understand this, because the most things not working correct and I don't know jasmine.

Maybe you can create a explanation how to create and run tests.

My failures: