Skip to content

Commit d9e2a89

Browse files
committed
Added better documentation. Adhere to style guide. Incorrect regex.
1 parent 701ff7e commit d9e2a89

2 files changed

Lines changed: 47 additions & 21 deletions

File tree

user_guide_src/source/_static/css/citheme.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ div#pulldown-menu {
205205
background: #252525;
206206
}
207207

208+
.wy-side-nav-search .logo {
209+
width: 100% !important;
210+
}
211+
208212
.wy-side-nav-search a {
209213
color: #ffffff;
210214
font-family: "Railway", "Helvetica", "Arial", sans-serif;

user_guide_src/source/_static/js/citheme.js

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,71 @@
55
* Into: ci-outgoing ci-api-responses
66
*/
77
window.onload = function() {
8-
const regexUrl = new RegExp(/([a-z0-9_.-]+)\/([a-z0-9_.-]+)\.html/);
8+
// Regular expression for finding chapter and subject in the current url
9+
const regexUrl = new RegExp(/\/([a-z0-9_.-]+)\/([a-z0-9_.-]+)\.html/);
10+
11+
// Get the current url
912
const currentUrl = window.location.href;
1013

11-
let urlMatch;
14+
// Get the document body
15+
const documentBody = document.body;
1216

13-
if ((urlMatch = regexUrl.exec(currentUrl)) !== null) {
14-
if (urlMatch.length === 3) {
15-
let parent = sanitizeClass(urlMatch[1]);
16-
let current = sanitizeClass(urlMatch[2]);
17+
// Placeholder for documentation index
18+
var index = null;
1719

18-
if (parent === 'html' || parent.length === 0) {
19-
parent = 'userguide';
20-
}
20+
if ((index = regexUrl.exec(currentUrl)) !== null)
21+
{
22+
// Sanitize the documentation chapter and subject
23+
var chapter = sanitizeClass(index[1]);
24+
var subject = sanitizeClass(index[2]);
2125

22-
addClass(parent);
23-
addClass(current);
26+
// Documentation are generated into an html-folder for developers.
27+
// This aren't a valid chapter. We are on documentation index.
28+
if (chapter === 'html')
29+
{
30+
index = null;
31+
}
32+
// Add chapter and subject className(s) to the document body
33+
else
34+
{
35+
addClass(documentBody, chapter);
36+
addClass(documentBody, subject);
2437
}
2538
}
39+
40+
// No chapter and subject found. We are on documentation index.
41+
if (index === null)
42+
{
43+
addClass(documentBody, 'documentation');
44+
addClass(documentBody, 'index');
45+
}
2646
}
2747

2848
/**
2949
* Sanitize the string - removing invalid characters
3050
*
31-
* @param {string} value Value to be sanitized
51+
* @param {string} className className to be sanitized
3252
*
3353
* @return {string}
3454
*/
35-
sanitizeClass = function(value) {
36-
return value.replace(/_/g, '-').replace(/[^a-z0-9-]/g, '');
55+
sanitizeClass = function(className) {
56+
return className.replace(/_/g, '-').replace(/[^a-z0-9-]/g, '');
3757
}
3858

3959
/**
40-
* Add class to the document body
60+
* Add class to HTML DOM Element Object
4161
*
42-
* @param {string} value Value to be added
43-
* @param {string} prefix Prefix to be added to all classnames
62+
* @param {object} el The HTML DOM Element Object
63+
* @param {string} className className to be added
64+
* @param {string} namePrefix namePrefix to be added to className
4465
*
4566
* @return {void}
4667
*/
47-
addClass = function(value, prefix) {
48-
prefix = prefix || 'ci-';
68+
addClass = function(el, className, namePrefix) {
69+
namePrefix = namePrefix || 'ci-';
4970

50-
if(value.length > 0) {
51-
document.body.classList.add(prefix + value);
71+
if (el.classList && className.length > 0)
72+
{
73+
el.classList.add(namePrefix + className);
5274
}
5375
}

0 commit comments

Comments
 (0)