Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support metadata #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Support commits metatada
Jérémie Bertrand committed Apr 27, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit bd747b768401f14d51dcf9c5d11b46055e9c727d
31 changes: 28 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -192,6 +192,10 @@ <h3>The axes of Semantic Release Notes </h3>
Additionally the release note should be able to indicate what category an item is. For instance,
"+New", "+Change", "+Bug-Fix", +Developer". This is indicated via a single word, or - (dash) delimited phrase, that has a "+" prefix.
</li>
<li>
<strong>Metadata</strong>:
A list of metadata can be added to a release note. Only some elements are possible, with their respective specific syntax.
</li>
<li>
<strong>Release</strong>:
As SRN allows for many releases to be defined within the one block of text, the system needs
@@ -314,6 +318,25 @@ <h3>Category</h3>
<pre class="object"></pre>
</div>

<h3>Metadata</h3>
<p>
It can be useful to add some metadata to a release note, for example the list of commits targeted by the release note.
</p>
<p>
Each supported metadata have it's own syntax, here is the list:
<ul>
<li>Commits: the word "commits" (case insensitive) followed by a colon, then the first and last commits separated by three dots, included or not in a link
</ul>
</p>
<div class="container">
<strong>Examples:</strong>
<pre class="code">commits:56af25a...d3fead4
Commits: [56af25a...d3fead4](https://github.com/Glimpse/Semantic-Release-Notes/compare/56af25a...d3fead4)
</pre>
<div class="result"></div>
<pre class="object"></pre>
</div>

<h3>Release (Not Working)</h3>
<p>
In some cases we want to have the one document that describes many releases. In this case, the
@@ -378,7 +401,7 @@ <h3>Release (Not Working)</h3>
<div>
<input name="menu-root-radio" class="menu-root-radio" id="Examples" type="radio" />
<div class="section-syntax">
<a id="Exmaples"></a>
<a id="Examples"></a>
<h2>Examples</h2>
<div class="section-editor">
<ul class="tabs">
@@ -455,7 +478,9 @@ <h2>Examples</h2>
# Plugin [[icon][http://getglimpse.com/release/icon/mvc.png]]
This description is specific to plugin section.
1. *Timeline*: Comes with an additional grid view to show the same data. +Changed
1. *Ajax*: Fix that crashed poll in Chrome and IE due to log/trace statement. +Fix [[i1234][http://getglimpse.com]]</pre>
1. *Ajax*: Fix that crashed poll in Chrome and IE due to log/trace statement. +Fix [[i1234][http://getglimpse.com]]

Commits: [56af25a...d3fead4](https://github.com/Glimpse/Semantic-Release-Notes/compare/56af25a...d3fead4)</pre>
<strong>Result:</strong>
<div class="result"></div>
<strong>Object:</strong>
@@ -518,7 +543,7 @@ <h2>Tools</h2>
</section>
<footer>
<div class="footer-inner">
Copyright &copy; 2013<br /> Anthony van der Hoorn &amp; Nik Molnar
Copyright &copy; 2015<br /> Anthony van der Hoorn &amp; Nik Molnar
</div>
</footer>
</div>
30 changes: 29 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
@@ -105,6 +105,28 @@ var processSyntax = (function () {
else
obj.sections[obj.sections.length - 1].items.push(item);
}
},
{
metadataPatterns : [{ name : 'Commits', pattern : /^(?:commits:)?[ ]*(?:([0-9a-f]{5,40}\.{3}[0-9a-f]{5,40})|(\[[0-9a-f]{5,40}\.{3}[0-9a-f]{5,40}\]\(https?:\/\/\S+\)))$/i }],
test : function (input) {
return this.metadataPatterns.some(function (element, index, array)
{
return element.pattern.test(input)
});
},
process : function (obj, input) {

for(var metadataPatternIndex in this.metadataPatterns) {
var metadataPattern = this.metadataPatterns[metadataPatternIndex];
var metadata = metadataPattern.pattern.exec(input);
if (metadata) {
if (!obj.metadata) {
obj.metadata = [];
}
obj.metadata.push({ name : metadataPattern.name, data : metadata[1] ? metadata[1] : metadata[2] });
}
}
}
}],
primary : {
pattern : /^[a-zA-Z0-9]/i,
@@ -237,7 +259,13 @@ var formatSyntax = (function () {

result += '<div><h1>' + feature.name + '</h1>' + processString(feature.summary) + processList(feature.items) + '</div>';
}


for (var metadataIndex in val.metadata) {
var metadata = val.metadata[metadataIndex];

result += '<div>' + metadata.name + ': ' + processString(metadata.data) + '</div>';
}

return result;
};