Skip to content

Commit

Permalink
Update with latest support docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikoff committed Nov 3, 2024
1 parent 0b81375 commit 2181428
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"grunt-contrib-less": "~2.1.0",
"grunt-contrib-pug": "~3.0.0",
"grunt-contrib-uglify": "~5.2.2",
"grunt-docs": "https://github.com/gruntjs/grunt-docs.git#d224f17ae21fe606b5b7eca73155a31f4e341930",
"grunt-docs": "https://github.com/gruntjs/grunt-docs.git#154b2b6ebc69c51bdf7cab5f2f54ce12b9d73eb1",
"grunt-sitemap": "~1.2.1",
"highlight.js": "~9.12.0",
"less-plugin-clean-css": "~1.6.0",
Expand Down
10 changes: 5 additions & 5 deletions src/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@import "hero-unit";
@import "wells";
@import "effects";
@import "blm";
@import "banner";

@text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);

Expand Down Expand Up @@ -170,9 +170,9 @@ i {
height: 340px;
width: 30%;
.logo {
height: 100%;
width: 100%;
position: relative;
height: 85%;
width: 90%;
background-size: cover;
z-index: 3;
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ i {
line-height: 1.6em;
margin-left: 0;
.sidebar-nav {
margin-top: 307px;
margin-top: 300px;
padding-left: 3em;
h3 {
margin-bottom: 0;
Expand Down
8 changes: 6 additions & 2 deletions src/tmpl/blocks/header.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.blm-banner
a(href='blm') Black Lives Matter
.banner
a(href='support') V1.6.1 is the current version, and previous versions are not supported. Upgrade to the latest version or consider other support options.
.navbar.navbar-inverse
.navbar-inner
.container
Expand All @@ -23,6 +23,10 @@
a(href='/documentation')
i.icon-file-text
span Documentation
li
a(href='/support')
i.icon-file-text
span Support
form.navbar-search.pull-right
input.search-query(type='text', placeholder='Search')
//.nav-collapse
139 changes: 78 additions & 61 deletions tasks/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
* Licensed under the MIT license.
*/

'use strict';
"use strict";

module.exports = function (grunt) {

var fs = require('fs');
var pug = require('pug');
var highlighter = require('highlight.js');
var docs = require('./lib/docs').init(grunt);
var marked = require('marked');
var fs = require("fs");
var pug = require("pug");
var highlighter = require("highlight.js");
var docs = require("./lib/docs").init(grunt);
var marked = require("marked");

/**
* Custom task to generate grunt documentation
*/
grunt.registerTask('docs', 'Compile Grunt Docs to HTML', function () {
grunt.registerTask("docs", "Compile Grunt Docs to HTML", function () {
var done = this.async();

/**
Expand All @@ -41,37 +40,44 @@ module.exports = function (grunt) {
var items = [];

// read the Home.md of the wiki, extract the section links
var lines = fs.readFileSync(base + 'Home.md').toString().split(/\r?\n/);
var lines = fs
.readFileSync(base + "Home.md")
.toString()
.split(/\r?\n/);
for (l in lines) {
var line = lines[l];

// choose a section of the file
if (line === section) {
rMode = true;
} else if (line.substring(0, 2) === '##') { // end of section
} else if (line.substring(0, 2) === "##") {
// end of section
rMode = false;
}

if (rMode && line.length > 0) {
var item = line.replace(/#/g, '').replace(']]', '').replace('* [[', '');
var item = line
.replace(/#/g, "")
.replace("]]", "")
.replace("- [[", "");
var url = item;

if (item[0] === ' ') {
if (item[0] === " ") {
// TODO: clean this up...
if (iconClass) {
items.push({
name: item.substring(1, item.length),
icon: iconClass
icon: iconClass,
});
} else {
items.push({
name: item.substring(1, item.length)
name: item.substring(1, item.length),
});
}
} else {
items.push({
name: item,
url: url.replace(/ /g, '-').toLowerCase()
url: url.replace(/ /g, "-").toLowerCase(),
});
}
}
Expand All @@ -83,126 +89,139 @@ module.exports = function (grunt) {
* Generate grunt guides documentation
*/
function generateGuides() {
grunt.log.ok('Generating Guides...');
grunt.log.ok("Generating Guides...");

// API Docs
var sidebars = [];
var names = grunt.file.expand({cwd: base}, ['*.md', '!grunt*.md', '!README.md']);
var names = grunt.file.expand({ cwd: base }, [
"*.md",
"!grunt*.md",
"!README.md",
]);

sidebars[0] = getSidebarSection('## Documentation', 'icon-file-text');
sidebars[1] = getSidebarSection('### Advanced');
sidebars[2] = getSidebarSection('### Community');
sidebars[3] = getSidebarSection('### Migration guides');
sidebars[0] = getSidebarSection("## Documentation", "icon-file-text");
sidebars[1] = getSidebarSection("### Advanced");
sidebars[2] = getSidebarSection("### Community");
sidebars[3] = getSidebarSection("### Migration guides");

names.forEach(function (name) {

var title = name.replace(/-/g, ' ').replace('.md', '');
var segment = name.replace(/ /g, '-').replace('.md', '').toLowerCase();
var title = name.replace(/-/g, " ").replace(".md", "");
var segment = name
.replace(/ /g, "-")
.replace(".md", "")
.toLowerCase();
var src = base + name;
var dest = 'build/docs/' + name.replace('.md', '').toLowerCase() + '.html';
var dest =
"build/docs/" + name.replace(".md", "").toLowerCase() + ".html";

grunt.file.copy(src, dest, {
process: function (src) {
try {
var file = 'src/tmpl/docs.pug';
var file = "src/tmpl/docs.pug";
var templateData = {
page: 'docs',
page: "docs",
rootSidebar: true,
pageSegment: segment,
title: title,
content: docs.anchorFilter(marked(docs.wikiAnchors(src))),
sidebars: sidebars
sidebars: sidebars,
};
return pug.compile(grunt.file.read(file), {filename: file})(templateData);
return pug.compile(grunt.file.read(file), { filename: file })(
templateData
);
} catch (e) {
grunt.log.error(e);
grunt.fail.warn('Pug failed to compile.');
grunt.fail.warn("Pug failed to compile.");
}
}
},
});
});
grunt.log.ok('Created ' + names.length + ' files.');
grunt.log.ok("Created " + names.length + " files.");
}


/**
* Generate grunt API documentation
*/
function generateAPI() {
grunt.log.ok('Generating API Docs...');
grunt.log.ok("Generating API Docs...");
// API Docs
var sidebars = [];
var names = grunt.file.expand({cwd: base}, ['grunt.*.md', '!*utils*']);
var names = grunt.file.expand({ cwd: base }, [
"grunt.*.md",
"!*utils*",
]);

names = names.map(function (name) {
return name.substring(0, name.length - 3);
});

// the default api page is special
names.push('grunt');
names.push("grunt");
// TODO: temporary store for these
names.push('Inside-Tasks');
names.push('Exit-Codes');
names.push("Inside-Tasks");
names.push("Exit-Codes");

// get docs sidebars
sidebars[0] = getSidebarSection('## API', 'icon-cog');
sidebars[1] = getSidebarSection('### Other');
sidebars[0] = getSidebarSection("## API", "icon-cog");
sidebars[1] = getSidebarSection("### Other");

names.forEach(function (name) {
var src = base + name + '.md';
var dest = 'build/api/' + name.toLowerCase() + '.html';
var src = base + name + ".md";
var dest = "build/api/" + name.toLowerCase() + ".html";
grunt.file.copy(src, dest, {
process: function (src) {
try {
var file = 'src/tmpl/docs.pug';
var file = "src/tmpl/docs.pug";
var templateData = {
page: 'api',
page: "api",
pageSegment: name.toLowerCase(),
title: name.replace(/-/g, ' '),
title: name.replace(/-/g, " "),
content: docs.anchorFilter(marked(docs.wikiAnchors(src))),
sidebars: sidebars
sidebars: sidebars,
};

return pug.compile(grunt.file.read(file), {filename: file})(templateData);
return pug.compile(grunt.file.read(file), { filename: file })(
templateData
);
} catch (e) {
grunt.log.error(e);
grunt.fail.warn('Pug failed to compile.');
grunt.fail.warn("Pug failed to compile.");
}
}
},
});
});
grunt.log.ok('Created ' + names.length + ' files.');
grunt.log.ok("Created " + names.length + " files.");
}

// Set default marked options
marked.setOptions({
gfm: true,
anchors: true,
base: '/',
base: "/",
pedantic: false,
sanitize: false,
// callback for code highlighter
highlight: function(code, lang) {
highlight: function (code, lang) {
// No language specified, no syntax highlighting.
if (!lang) {
return code;
}
// Handle common abbreviations.
var langMap = {
js: 'javascript',
shell: 'bash',
html: 'xml'
js: "javascript",
shell: "bash",
html: "xml",
};
if (lang in langMap) {
lang = langMap[lang];
}
try {
return highlighter.highlight(lang, code).value;
} catch (error) {
grunt.log.error('[lang: %s] %s', lang, error.message);
return 'ERROR';
grunt.log.error("[lang: %s] %s", lang, error.message);
return "ERROR";
}
}
},
});

// grunt guides - wiki articles that are not part of the grunt api
Expand All @@ -214,8 +233,6 @@ module.exports = function (grunt) {
}

// In the future this will run multiple times for different versions.
generateDocs('node_modules/grunt-docs/');

generateDocs("node_modules/grunt-docs/");
});

};

0 comments on commit 2181428

Please sign in to comment.