Skip to content

Commit

Permalink
Updates event name simplification regexp to support colon-separated e…
Browse files Browse the repository at this point in the history
…vent names, changes function name to prevent misuse.
  • Loading branch information
Mike Harty committed Jan 29, 2016
1 parent ef30c6e commit 41a45cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions publish.js
Expand Up @@ -168,11 +168,10 @@ function find(spec) {
return helper.find(data, spec);
}

function simplifyName(namepath) {
// Doesn't necessarily handle all types yet. Just doing this for events for now.
var regex = /"(.*)"$|[:#~\.](\w*)$/;
var matches = namepath.match(regex);
return matches[1] || matches[2] || namepath;
function simplifyEventName(namepath) {
var regex = /#(event:)?(.*)$/;
var matches = namepath.match(regex);
return matches[2] || namepath;
}

function formattedParent(data) {
Expand Down Expand Up @@ -944,7 +943,7 @@ exports.publish = function(taffyData, opts, tutorials) {
view.elementId = elementId;
view.sectionId = sectionId;
view.subsectionId = subsectionId;
view.simplifyName = simplifyName;
view.simplifyEventName = simplifyEventName;
view.formattedParent = formattedParent;
view.resolveAuthorLinks = resolveAuthorLinks;
view.htmlsafe = htmlsafe;
Expand Down
2 changes: 1 addition & 1 deletion tmpl/method.tmpl
Expand Up @@ -77,7 +77,7 @@ var hasDescription = !_.isEmpty(data.description)
<?js if (data.fires && fires.length) { ?>
<h5>Fires</h5>
<ul class="fired-event-list"><?js fires.forEach(function(f) { ?>
<li class="fired-event-item"><code class="event-name"><?js= self.linkto(f, '"' + self.simplifyName(f) + '"') ?></code></li>
<li class="fired-event-item"><code class="event-name"><?js= self.linkto(f, '"' + self.simplifyEventName(f) + '"') ?></code></li>
<?js }); ?></ul>
<?js } ?>

Expand Down

0 comments on commit 41a45cc

Please sign in to comment.