Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit bda2755

Browse files
[Doc] added code to support showing command docs for each patch and master (#350)
Co-authored-by: Samiya Akhtar <[email protected]>
1 parent e2f6df1 commit bda2755

File tree

6 files changed

+116
-11
lines changed

6 files changed

+116
-11
lines changed

docs/commands/data.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"description": "Removes previously launched instances of the dashboard",
100100
"defaultValue": false
101101
}
102-
]
102+
],
103+
"markdown": "## Description\n\nThis command launches the Service Introspection Dashboard for your current\nconfiguration. It requires `docker` to be installed on your machine in order to\nwork.\n"
103104
},
104105
"deployment get": {
105106
"command": "get",
@@ -151,7 +152,8 @@
151152
"description": "Watch the deployments for a live view",
152153
"defaultValue": false
153154
}
154-
]
155+
],
156+
"markdown": "## Description\n\nThis commands retrieves the list of deployments by service name, release\nenvironment, build ID, commit ID, or container image tag.\n"
155157
},
156158
"deployment onboard": {
157159
"command": "onboard",
@@ -201,7 +203,8 @@
201203
"description": "The Azure subscription id",
202204
"required": true
203205
}
204-
]
206+
],
207+
"markdown": "## Description\n\nPrepare storage for the service introspection tool. This will create a storage\naccount if it does not already exist in your subscription in the given\n`resource-group`. The storage table will also be created in a newly created or\nin an existing storage account if it does not exist already. When the Azure Key\nVault argument is specified, a secret with Azure storage access key will be\ncreated. Otherwise, the storage access key will need to be specified in\nenvironment variables manually.\n\nSee\n[Prerequisites](https://github.com/CatalystCode/spk/blob/master/guides/service-introspection.md#prerequisites)\n"
205208
},
206209
"deployment validate": {
207210
"command": "validate",
@@ -364,7 +367,7 @@
364367
"required": true
365368
},
366369
{
367-
"arg": "-d, --hld-repo-url <hld-repo-url>",
370+
"arg": "-U, --hld-repo-url <hld-repo-url>",
368371
"description": "The high level definition (HLD) git repo url; falls back to azure_devops.org in spk config.",
369372
"required": true
370373
},
@@ -389,7 +392,7 @@
389392
"required": true
390393
},
391394
{
392-
"arg": "--project <project>",
395+
"arg": "-d, --devops-project <project>",
393396
"description": "Azure DevOps project name; falls back to azure_devops.project in spk config.",
394397
"required": true
395398
},
@@ -644,7 +647,7 @@
644647
"description": "Azure DevOps organization name; falls back to azure_devops.org in spk config"
645648
},
646649
{
647-
"arg": "-p, --project <project>",
650+
"arg": "-d, --devops-project <project>",
648651
"description": "Azure DevOps project name; falls back to azure_devops.project in spk config"
649652
},
650653
{

docs/commands/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@
5454
<div class="content-left">
5555
<div class="title">SPK Commands</div>
5656
<div>
57+
58+
<div class="moniker-picker2" data-bi-name="moniker-picker" style="width:90%;margin-left:4px">
59+
<div class="dropdown has-margin-bottom-small">
60+
<button id="btnSelectRelease" class="dropdown-trigger has-flex-justify-content-start is-full-width button is-small has-border has-inner-focus" aria-expanded="false" aria-controls="ax-3">
61+
<span class="visually-hidden"><!---->Select Version<!----></span>
62+
<span id="selectedRelease" class="has-text-overflow-ellipsis"></span>
63+
<span class="dropdown-button-chevron" aria-hidden="true">
64+
<span class="icon docon docon-chevron-down-light expanded-indicator"></span>
65+
</span>
66+
</button>
67+
<ul id="ulReleases" class="dropdown-menu is-full-width is-vertically-scrollable" id="ax-3" aria-label="Azure CLI" style="left: 0px; max-height: 140px;">
68+
</ul>
69+
</div>
70+
</div>
71+
5772
<div class="control has-icons-left">
5873
<input id="commandfilter" role="combobox" maxlength="100" aria-autocomplete="list" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" id="ax-0" class="autocomplete-input input control has-icons-left is-small is-full-width" type="text" aria-expanded="false" aria-owns="ax-1-listbox" aria-activedescendant="" placeholder="Filter by command">
5974

docs/commands/releases.txt

Whitespace-only changes.

docs/commands/spk.js

+81-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,82 @@
11
var data = null;
22
var filter = "";
33
var converter = new showdown.Converter();
4+
var releases = ["master"];
5+
var version = "master";
6+
var sepVersion = "@";
47

58
var template =
69
'<p class="cmd-title">@@main-cmd@@</p><p class="cmd-description">@@cmd-description@@</p><p>&nbsp;</p><p>Options:</p>@@options@@<p>&nbsp;</p>';
710
var optionTemplate =
811
'<p>@@option@@</p><p class="cmd-description">@@description@@</p><div class="line-space"></div>';
12+
var relTemplate =
13+
'<li><a class="preserve-view button is-small has-border-none has-inner-focus has-flex-justify-content-start is-full-width has-text-wrap is-text-left">@@value@@</a></li>';
914

1015
function sanitize(str) {
1116
return str.replace("<", "&lt;").replace(">", "&gt;");
1217
}
1318

19+
function getExistingVersions() {
20+
$.ajax({
21+
url: "releases.txt",
22+
success: function(result) {
23+
result.split("\n").forEach(function(r) {
24+
var rTrim = r.trim();
25+
if (rTrim && releases.indexOf(rTrim) === -1) {
26+
releases.push(rTrim);
27+
}
28+
});
29+
releases.sort(function(a, b) {
30+
return a > b ? -1 : 1;
31+
});
32+
},
33+
async: false
34+
});
35+
}
36+
37+
function getVersion() {
38+
if (window.location.hash) {
39+
var val = window.location.hash.substring(1); // remove #
40+
var idx = val.indexOf(sepVersion);
41+
if (idx !== -1) {
42+
ver = val.substring(0, idx).trim();
43+
if (releases.indexOf(ver) !== -1) {
44+
version = ver;
45+
return;
46+
}
47+
}
48+
}
49+
version = "master";
50+
}
51+
52+
function populateVersionList() {
53+
var oSelect = $("#ulReleases");
54+
oSelect.html(
55+
releases.reduce((a, c) => {
56+
return a + relTemplate.replace("@@value@@", c);
57+
}, "")
58+
);
59+
oSelect.find("li").each(function(i, elm) {
60+
$(elm).on("click", function(evt) {
61+
evt.stopPropagation();
62+
oSelect.css("display", "none");
63+
var ver = $(this).text();
64+
if (ver !== version) {
65+
version = ver;
66+
$("#selectedRelease").text(version);
67+
loadCommands();
68+
}
69+
});
70+
});
71+
}
72+
1473
function showDetails(key) {
1574
if (!key) {
16-
window.location.hash = "";
75+
window.location.hash = "#" + version + sepVersion;
1776
$("#spk-details").html("");
1877
return;
1978
}
20-
window.location.hash = key.replace(/\s/g, "_");
79+
window.location.hash = version + sepVersion + key.replace(/\s/g, "_");
2180
var cmd = data[key];
2281
var valuesArray = cmd.command.split(/\s/);
2382
var values = "";
@@ -84,7 +143,12 @@ function populateListing() {
84143
);
85144
}
86145
if (window.location.hash) {
87-
var key = window.location.hash.replace(/_/g, " ").substring(1); // remove #
146+
var hashTag = window.location.hash.substring(1); // remove #
147+
var idx = hashTag.indexOf(sepVersion);
148+
if (idx !== -1) {
149+
hashTag = hashTag.substring(idx + 1);
150+
}
151+
var key = hashTag.replace(/_/g, " ");
88152
if (cmdKeys.indexOf(key) !== -1) {
89153
showDetails(key);
90154
} else {
@@ -109,8 +173,9 @@ var subheaderItems = function() {
109173
});
110174
};
111175

112-
$(function() {
113-
$.getJSON("./data.json", function(json) {
176+
function loadCommands() {
177+
var url = version === "master" ? "./data.json" : "./data" + version + ".json";
178+
$.getJSON(url, function(json) {
114179
data = json;
115180
subheaderItems();
116181
populateListing();
@@ -123,4 +188,15 @@ $(function() {
123188
populateListing();
124189
});
125190
});
191+
}
192+
193+
$(function() {
194+
$("#btnSelectRelease").on("click", function() {
195+
$("#ulReleases").css("display", "block");
196+
});
197+
getExistingVersions();
198+
getVersion();
199+
$("#selectedRelease").text(version);
200+
populateVersionList();
201+
loadCommands();
126202
});

docs/commands/styles/spk.css

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ a:visited {
111111
}
112112
#commandfilter {
113113
width: 90% !important;
114+
margin-left: 4px;
114115
margin-bottom: 8px;
115116
}
116117
.input-icon {
@@ -119,3 +120,7 @@ a:visited {
119120
.small-font {
120121
font-size: 0.875rem;
121122
}
123+
#releases {
124+
margin-left: 4px !important;
125+
width: 90% !important;
126+
}

scripts/release-version-bump.sh

+6
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ yarn config set version-git-message "release: ${RELEASE_TYPE} bump to v%s"
2727

2828
# Bump version following the specified release type format
2929
yarn version "--${RELEASE_TYPE}"
30+
31+
# copy a version of the command docs
32+
VERSION=$(cat package.json | grep '"version"' | sed -En 's/ "version": "(.*)",/\1/p')
33+
echo "${VERSION}" >> docs/commands/releases.txt
34+
cp docs/commands/data.json "docs/commands/data${VERSION}.json"
35+
3036
git push ${REMOTE} ${RELEASE_BRANCH}

0 commit comments

Comments
 (0)