| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 140611b commit 7043e95
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -323,6 +323,8 @@ function processList(section) { | |||
| 323 | 323 | delete section.list; | |
| 324 | 324 | } | |
| 325 | 325 | ||
| 326 | + const paramExpr = /\((.*)\);?$/; | ||
| 327 | + | ||
| 326 | 328 | // textRaw = "someobject.someMethod(a[, b=100][, c])" | |
| 327 | 329 | function parseSignature(text, sig) { | |
| 328 | 330 | var params = text.match(paramExpr); | |
@@ -556,42 +558,23 @@ function deepCopy_(src) { | |||
| 556 | 558 | ||
| 557 | 559 | ||
| 558 | 560 | // These parse out the contents of an H# tag. | |
| 559 | - const eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i; | ||
| 560 | - const classExpr = /^Class:\s*([^ ]+).*$/i; | ||
| 561 | - const propExpr = /^[^.]+\.([^ .()]+)\s*$/; | ||
| 562 | - const braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/; | ||
| 563 | - const classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i; | ||
| 564 | - const methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/; | ||
| 565 | - const newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/; | ||
| 566 | - var paramExpr = /\((.*)\);?$/; | ||
| 567 | - | ||
| 568 | - function newSection(tok) { | ||
| 569 | - const section = {}; | ||
| 561 | + const headingExpressions = [ | ||
| 562 | + { type: 'event', re: /^Event(?::|\s)+['"]?([^"']+).*$/i }, | ||
| 563 | + { type: 'class', re: /^Class:\s*([^ ]+).*$/i }, | ||
| 564 | + { type: 'property', re: /^[^.[]+(\[[^\]]+\])\s*$/ }, | ||
| 565 | + { type: 'property', re: /^[^.]+\.([^ .()]+)\s*$/ }, | ||
| 566 | + { type: 'classMethod', re: /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i }, | ||
| 567 | + { type: 'method', re: /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/ }, | ||
| 568 | + { type: 'ctor', re: /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/ }, | ||
| 569 | + ]; | ||
| 570 | + | ||
| 571 | + function newSection({ text }) { | ||
| 570 | 572 | // Infer the type from the text. | |
| 571 | - const text = section.textRaw = tok.text; | ||
| 572 | - if (text.match(eventExpr)) { | ||
| 573 | - section.type = 'event'; | ||
| 574 | - section.name = text.replace(eventExpr, '$1'); | ||
| 575 | - } else if (text.match(classExpr)) { | ||
| 576 | - section.type = 'class'; | ||
| 577 | - section.name = text.replace(classExpr, '$1'); | ||
| 578 | - } else if (text.match(braceExpr)) { | ||
| 579 | - section.type = 'property'; | ||
| 580 | - section.name = text.replace(braceExpr, '$1'); | ||
| 581 | - } else if (text.match(propExpr)) { | ||
| 582 | - section.type = 'property'; | ||
| 583 | - section.name = text.replace(propExpr, '$1'); | ||
| 584 | - } else if (text.match(classMethExpr)) { | ||
| 585 | - section.type = 'classMethod'; | ||
| 586 | - section.name = text.replace(classMethExpr, '$1'); | ||
| 587 | - } else if (text.match(methExpr)) { | ||
| 588 | - section.type = 'method'; | ||
| 589 | - section.name = text.replace(methExpr, '$1'); | ||
| 590 | - } else if (text.match(newExpr)) { | ||
| 591 | - section.type = 'ctor'; | ||
| 592 | - section.name = text.replace(newExpr, '$1'); | ||
| 593 | - } else { | ||
| 594 | - section.name = text; | ||
| 573 | + for (const { type, re } of headingExpressions) { | ||
| 574 | + const [, name] = text.match(re) || []; | ||
| 575 | + if (name) { | ||
| 576 | + return { textRaw: text, type, name }; | ||
| 577 | + } | ||
| 595 | 578 | } | |
| 596 | - return section; | ||
| 579 | + return { textRaw: text, name: text }; | ||
| 597 | 580 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments