spec-up-t 0.11.12 → 0.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/compiled/body.js +1 -1
- package/assets/js/edit-term-buttons.js +6 -6
- package/index.js +2 -6
- package/package.json +1 -1
- package/readme.md +32 -11
- package/src/get-xrefs-data.js +17 -10
- package/docs/index.html +0 -2489
- package/src/fix-content.js +0 -59
package/assets/compiled/body.js
CHANGED
|
@@ -50,7 +50,7 @@ window.FontAwesomeKitConfig={asyncLoading:{enabled:!0},autoA11y:{enabled:!0},bas
|
|
|
50
50
|
* @license MIT
|
|
51
51
|
* @since 2024-06-09
|
|
52
52
|
*/
|
|
53
|
-
function editTermButtons(){
|
|
53
|
+
function editTermButtons(){document.querySelector(".terms-and-definitions-list");const t=((e=specConfig.spec_directory).startsWith("./")?e=e.substring(2):e.startsWith("/")&&(e=e.substring(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e);var e;document.querySelectorAll('span[id^="term:"]').forEach(e=>{const s=e.getAttribute("id").split(":")[1];e.innerHTML+=`<sup class="edit-term-button-sup"><a target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="edit-term-button">Edit</a></sup><sup class="history-term-button-sup"><a target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="history-term-button">History</a></sup>`})}document.addEventListener("DOMContentLoaded",(function(){editTermButtons()}));
|
|
54
54
|
function inPageSearch(){const e=document.querySelector("span[issue-count]"),t=specConfig.searchHighlightStyle||"ssi",n="search-h7vc6omi2hr2880",i=document.querySelector("main article");let c=document.createElement("div");c.setAttribute("id","container-"+n),c.setAttribute("class","container-"+n),e.after(c);let o=document.createElement("input");o.setAttribute("type","text"),o.setAttribute("id",n),o.setAttribute("placeholder","🔍"),c.appendChild(o),setTimeout(()=>{o.focus()},1e3);const r=document.createElement("div");r.setAttribute("id","back-and-forth-buttons-container-"+n);const a=document.createElement("button");a.setAttribute("id","one-match-backward-"+n),a.setAttribute("disabled","disabled"),a.setAttribute("title","Go to previous match. Shortcut key: Left Arrow"),a.textContent="▲",r.appendChild(a);const s=document.createElement("button");s.setAttribute("id","one-match-forward-"+n),s.setAttribute("disabled","disabled"),s.setAttribute("title","Go to next match. Shortcut key: Right Arrow"),s.textContent="▼",r.appendChild(s),c.appendChild(r);const d=document.createElement("span");d.setAttribute("id","total-matches-"+n),d.innerHTML="0 matches",c.appendChild(d),o.addEventListener("input",(function(){f(o.value)}));const h="highlight-matches-"+n,l={dif:"highlight-matches-DIF-search-h7vc6omi2hr2880",toip:"highlight-matches-ToIP-search-h7vc6omi2hr2880",btc:"highlight-matches-BTC-search-h7vc6omi2hr2880",keri:"highlight-matches-KERI-search-h7vc6omi2hr2880",ssi:"highlight-matches-SSI-search-h7vc6omi2hr2880",gleif:"highlight-matches-GLEIF-search-h7vc6omi2hr2880"}[t.toLowerCase()];let u=0,m=-1;function b(e){e.scrollIntoView({behavior:"smooth",block:"start"});const t=e.getBoundingClientRect(),n=t.top+window.pageYOffset-(window.innerHeight-t.height)/2;window.scrollTo({top:n,behavior:"smooth"})}function p(){m<=0?document.getElementById("one-match-backward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-backward-"+n).removeAttribute("disabled"),m>=u-1?document.getElementById("one-match-forward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-forward-"+n).removeAttribute("disabled")}function g(){d.innerHTML=u+" matches"}const f=function(e,t){let n;return function(){const i=this,c=arguments;clearTimeout(n),n=setTimeout(()=>e.apply(i,c),t)}}((function(e){if(function(){document.querySelectorAll("span."+h).forEach(e=>{Array.from(e.childNodes).forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&e.removeChild(t)}),e.classList.contains(h)&&(e.outerHTML=e.innerHTML)})}(),u=0,m=-1,""===e)return void g();let t=0;!function i(c){if(3===c.nodeType){const i=function(i){const c=i.nodeValue,o=new RegExp(e,"gi");let r,a=0,s=document.createDocumentFragment();for(;null!==(r=o.exec(c));){s.appendChild(document.createTextNode(c.substring(a,r.index)));const e=document.createElement("span");e.textContent=r[0],e.classList.add(h),e.classList.add(l),e.setAttribute("id",n+"-"+t),s.appendChild(e),u=t+1,t++,a=r.index+r[0].length}return s.appendChild(document.createTextNode(c.substring(a))),s}(c);i.childNodes.length>1&&c.parentNode.replaceChild(i,c)}else 1===c.nodeType&&Array.from(c.childNodes).forEach(i)}(i);let c=document.querySelector("."+l);null!==c&&b(c);g(),p(),m=-1}),600);a.addEventListener("click",(function(){m--;const e=document.querySelector("#"+n+"-"+m);e&&b(e),e.classList.add("active"),setTimeout(()=>{e.classList.remove("active")},3e3),p()})),s.addEventListener("click",(function(){m++;const e=document.querySelector("#"+n+"-"+m);e&&b(e),e.classList.add("active"),setTimeout(()=>{e.classList.remove("active")},3e3),p()})),document.addEventListener("keyup",e=>{switch(e.key){case"ArrowRight":s.click();break;case"ArrowLeft":a.click()}})}document.addEventListener("DOMContentLoaded",(function(){inPageSearch()}));
|
|
55
55
|
function highlightMenuItems(){let t=null;function e(t){document.querySelectorAll("#toc_list a").forEach(t=>{t.classList.remove("highlight-cfib41dyhcd99sm")});const e=document.querySelector(`#toc_list a[href="#${t.id}"]`);e&&(e.classList.add("highlight-cfib41dyhcd99sm"),e.scrollIntoView({behavior:"smooth",block:"center"}))}const o=new IntersectionObserver((o,n)=>{const c=o.filter(t=>t.isIntersecting).map(t=>t.target);c.length>0?(t=c[0],e(t)):t&&e(t)},{root:null,rootMargin:"0px",threshold:.1});document.querySelectorAll("h2, h3, h4, h5, h6").forEach(t=>o.observe(t))}document.addEventListener("DOMContentLoaded",(function(){highlightMenuItems()}));
|
|
56
56
|
function backToTop(){const n=document.createElement("a");n.id="back-to-top-a1zncgtqfpzsig8",n.href="#content",n.innerHTML="↑",document.body.appendChild(n);const t=function(n,t){let e;return function(){const o=this,c=arguments;clearTimeout(e),e=setTimeout(()=>n.apply(o,c),t)}}((function(){window.scrollY>300?n.style.display="flex":n.style.display="none"}),600);window.addEventListener("scroll",(function(){t()}))}document.addEventListener("DOMContentLoaded",(function(){backToTop()}));
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
function editTermButtons() {
|
|
10
|
-
//
|
|
11
|
-
const termsDefinitions = document.querySelector('.terms-and-definitions-list');
|
|
10
|
+
// Find the definition list. This does not work ok. Disabled for now.
|
|
11
|
+
// const termsDefinitions = document.querySelector('.terms-and-definitions-list');
|
|
12
12
|
|
|
13
13
|
// Remove "./" or "/" from the beginning of a string and "/" at the end of the string
|
|
14
14
|
function cleanPath(path) {
|
|
@@ -30,15 +30,15 @@ function editTermButtons() {
|
|
|
30
30
|
// Example usage with the string from the file
|
|
31
31
|
|
|
32
32
|
const cleanedSpecDir = cleanPath(specConfig.spec_directory);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const url = term.
|
|
33
|
+
|
|
34
|
+
document.querySelectorAll('span[id^="term:"]').forEach(term => {
|
|
35
|
+
const url = term.getAttribute('id');
|
|
36
36
|
|
|
37
37
|
// cut “url” on the “:” and keep the second part
|
|
38
38
|
const fileName = url.split(":")[1];
|
|
39
39
|
|
|
40
40
|
// add edit and history buttons to term
|
|
41
|
-
term.innerHTML += `<sup class="edit-term-button-sup"><a target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/
|
|
41
|
+
term.innerHTML += `<sup class="edit-term-button-sup"><a target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/main/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="edit-term-button">Edit</a></sup><sup class="history-term-button-sup"><a target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/main/${cleanedSpecDir}/${specConfig.spec_terms_directory}/${fileName}.md" class="history-term-button">History</a></sup>`;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
package/index.js
CHANGED
|
@@ -6,7 +6,6 @@ module.exports = function(options = {}) {
|
|
|
6
6
|
validateReferences,
|
|
7
7
|
findExternalSpecByKey
|
|
8
8
|
} = require('./references.js');
|
|
9
|
-
const {getXrefsData} = require('./src/get-xrefs-data.js');
|
|
10
9
|
const gulp = require('gulp');
|
|
11
10
|
const fs = require('fs-extra');
|
|
12
11
|
const path = require('path');
|
|
@@ -31,11 +30,8 @@ module.exports = function(options = {}) {
|
|
|
31
30
|
}
|
|
32
31
|
];
|
|
33
32
|
|
|
34
|
-
// Test if xrefs-data.js exists
|
|
35
|
-
|
|
36
|
-
const projectRoot = process.cwd();
|
|
37
|
-
// Create a path for the output file in the project root:
|
|
38
|
-
const inputPath = path.join(projectRoot, 'output/xrefs-data.js');
|
|
33
|
+
// Test if xrefs-data.js exists, else make it an empty string
|
|
34
|
+
const inputPath = 'output/xrefs-data.js';
|
|
39
35
|
let xrefsData = "";
|
|
40
36
|
|
|
41
37
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.13",
|
|
4
4
|
"description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
|
|
5
5
|
"main": "./index",
|
|
6
6
|
"repository": {
|
package/readme.md
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
|
+
# Spec-Up-T
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
5
|
<img src="./specup_logo.png">
|
|
6
6
|
|
|
7
|
-
<
|
|
7
|
+
<h2 style="display: block; margin: 0 auto; text-align: center;">Markdown » Spec-Up</h2>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
## Intro
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
Spec-Up is a technical specification development tool that enables you to create rich specification documents for standards bodies and engineering projects by writing in an extended version of markdown that features all the bells and whistles - for example: advanced syntax highlighting, notice blocks, complex tables, charts, UML diagrams, and more.
|
|
10
13
|
|
|
14
|
+
Spec-Up-T is an expansion of [DIF's Spec-Up](https://github.com/decentralized-identity/spec-up) specifically for the needs of the Trust-over-IP foundation. Read more in the elaborate motivation in this technical article [Spec-Up-T, the ToIP Terms extension of Spec-Up](https://hackmd.io/s1TEBBluQBSL10ZT5yRVPw)
|
|
11
15
|
|
|
16
|
+
## Extension
|
|
12
17
|
|
|
13
|
-
Spec-Up
|
|
18
|
+
Spec-Up-T stays in sync with Spec-Up, and currently adds the following extra functionality:
|
|
19
|
+
1. Search & Find
|
|
20
|
+
2. Splitter for Terms and Definition section following the [Termininology Governance Guide](https://trustoverip.github.io/ctwg-terminology-governance-guide/) and various meeting report since [CTWG April 2024](https://wiki.trustoverip.org/display/HOME/2024-04-22+CTWG+Meeting+Notes).
|
|
14
21
|
|
|
15
22
|
## Setup
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
Install Spec-Up-T as follows:
|
|
25
|
+
|
|
26
|
+
- Open your terminal and go to the target directory
|
|
27
|
+
- Run `npx create-spec-up-starterpack@latest`
|
|
28
|
+
This will create a working Spec-Up-T installation in a new directory called `spec-up-t-starter-pack`
|
|
29
|
+
|
|
30
|
+
- Rename this directory to your liking, for example `my-new-specification`
|
|
31
|
+
- Go into this dir:
|
|
32
|
+
`cd my-new-specification`
|
|
33
|
+
You are now in this dir.
|
|
34
|
+
|
|
35
|
+
- Install all dependencies:
|
|
36
|
+
`npm run install`
|
|
37
|
+
|
|
38
|
+
Now you have a basic Spec-Up-T install with the following content:
|
|
39
|
+
- a `specs.json` file
|
|
40
|
+
- a `spec/` directory with a sample markdown files
|
|
41
|
+
- (and more)
|
|
18
42
|
|
|
19
|
-
|
|
20
|
-
1. Run `npm install spec-up` in the root directory of the repo to install all dependencies.
|
|
21
|
-
2. Create a `specs.json` file **in the root folder of your repository** to specify configuration values used in the generation of your spec documents. The values in your `specs.json` file include things like where your spec's markdown files are located, where to output the generated spec document, and various metadata values used in rendering, such as the title, logo, and repo links for each of your specs. The following are the required/optional fields supported in the `specs.json` config file:
|
|
43
|
+
The`specs.json` file **in the root folder of your repository** specifies configuration values used in the generation of your spec documents. The values in your `specs.json` file include things like where your spec's markdown files are located, where to output the generated spec document, and various metadata values used in rendering, such as the title, logo, and repo links for each of your specs. The following are the required/optional fields supported in the `specs.json` config file:
|
|
22
44
|
|
|
23
45
|
- **`public_root`** _(PATH STRING, optional)_ - For some platforms and services where you may want to output your rendered spec, the pathing may differ from the directory structure of your local project. To account for this, you can use the `public_root` property to specify the insertion of a path segment to account for the different in pathing between your local renders and wherever you publish your spec to.
|
|
24
46
|
- **`specs`** _(ARRAY, required)_ - the `specs` array contains descriptor objects for each of the specs you are generating in your project, and are composed of the following required and optional properties:
|
|
@@ -38,9 +60,8 @@ Installing Spec-Up is easy peasy lemon squeezy:
|
|
|
38
60
|
"repo": "sidetree"
|
|
39
61
|
}
|
|
40
62
|
```
|
|
41
|
-
3. In your main node.js file, or as a package.json script entry, use this invocation call: `require('spec-up')()`
|
|
42
63
|
|
|
43
|
-
|
|
64
|
+
You're ready to start rendering specs as HTML sites locally and/or pushing them to github pages however you see fit to automate.
|
|
44
65
|
|
|
45
66
|
## Running the scripts locally
|
|
46
67
|
|
package/src/get-xrefs-data.js
CHANGED
|
@@ -6,19 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// Get the current working directory
|
|
9
|
-
|
|
10
|
-
const path = require('path');
|
|
9
|
+
|
|
11
10
|
const fs = require('fs-extra');
|
|
12
|
-
const config = fs.readJsonSync(
|
|
11
|
+
const config = fs.readJsonSync('specs.json');
|
|
13
12
|
const specDirectories = config.specs.map(spec => spec.spec_directory + '/' + spec.spec_terms_directory);
|
|
14
13
|
|
|
15
14
|
// Create directory named “output” in the project root if it does not yet exist
|
|
16
|
-
if (!fs.existsSync(
|
|
17
|
-
fs.mkdirSync(
|
|
15
|
+
if (!fs.existsSync('output')) {
|
|
16
|
+
fs.mkdirSync('output');
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
// Create a path for the output file in the project root
|
|
21
|
-
const outputPath =
|
|
20
|
+
const outputPath = 'output/xrefs-data.js';
|
|
22
21
|
|
|
23
22
|
function getXrefsData() {
|
|
24
23
|
let allXrefs = {};
|
|
@@ -55,39 +54,47 @@ function getXrefsData() {
|
|
|
55
54
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
56
55
|
}
|
|
57
56
|
|
|
57
|
+
console.log(`Github API request for the term “${match.term}” was successful`);
|
|
58
|
+
|
|
58
59
|
// Extract JSON data from the response
|
|
59
60
|
const data = await response.json();
|
|
60
61
|
|
|
61
62
|
// Check if there are any commits
|
|
62
63
|
if (data.length === 0) {
|
|
63
|
-
console.log(
|
|
64
|
+
console.log(`No commit hash found for the term “${match.term}”`);
|
|
64
65
|
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
// Process the last ten commits
|
|
69
70
|
const commits = data.slice(0, 1); // Get only the last commit
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const commitHash = commits.map(commit => commit.sha);
|
|
72
|
+
|
|
73
|
+
console.log(`Commit hash found for the term “${match.term}”: `, commitHash);
|
|
74
|
+
return commitHash;
|
|
72
75
|
|
|
73
76
|
// return;
|
|
74
77
|
} catch (error) {
|
|
75
|
-
console.error(
|
|
78
|
+
console.error(`Failed to fetch commit hash for the term “${match.term}”:`, error);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
// Go through all directories that contain files with a term and definition
|
|
83
|
+
console.log('All “spec_directory” found in specs.json: ', specDirectories);
|
|
80
84
|
specDirectories.forEach(specDirectory => {
|
|
85
|
+
console.log(`Current spec_directory: `, specDirectory);
|
|
81
86
|
// read directory
|
|
82
87
|
fs.readdirSync(specDirectory).forEach(file => {
|
|
83
88
|
// read file
|
|
84
89
|
if (file.endsWith('.md')) {
|
|
90
|
+
console.log(`Markdown file referenced in spec_directory: `, file);
|
|
85
91
|
const markdown = fs.readFileSync(`${specDirectory}/${file}`, 'utf8');
|
|
86
92
|
// create regex that finds “[[xref:.*]]”
|
|
87
93
|
const regex = /\[\[xref:.*?\]\]/g;
|
|
88
94
|
if (regex.test(markdown)) {
|
|
89
95
|
const xrefs = markdown.match(regex);
|
|
90
96
|
xrefs.forEach(xref => {
|
|
97
|
+
console.log(`Xref found in ${file}: `, xref);
|
|
91
98
|
// example of xref: [[xref: PE, Holder]]
|
|
92
99
|
allXrefs.xrefs.add(xref);
|
|
93
100
|
});
|