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

Add hyphenation hints on compile time & use text justification #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"type": "git",
"url": "https://github.com/clenemt/docdash.git"
},
"dependencies": {
"hyphenation.en-gb": "^0.2.1",
"hypher": "^0.2.5",
"jsdom": "^15.1.1"
},
"devDependencies": {
"jsdoc": "latest",
"browser-sync": "latest",
Expand Down
39 changes: 37 additions & 2 deletions publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ var path = require('jsdoc/path');
var taffy = require('taffydb').taffy;
var template = require('jsdoc/template');
var util = require('util');
var jsdom = require('jsdom');
var Hypher = require('hypher');
var hypher_en = require('hyphenation.en-gb');

var hypher = new Hypher(hypher_en);
var htmlsafe = helper.htmlsafe;
var linkto = helper.linkto;
var resolveAuthorLinks = helper.resolveAuthorLinks;
Expand Down Expand Up @@ -475,6 +479,35 @@ function buildNav(members) {
return nav;
}

function hyphenate_dom(node) {
if (node.nodeName === '#text') {
node.nodeValue = hypher.hyphenateText(node.nodeValue);
}
for (const child of node.childNodes) {
hyphenate_dom(child);
}
}

function hyphenate_prop(obj, prop) {
var dom = new jsdom.JSDOM(obj[prop]);
hyphenate_dom(dom.window.document.body);
obj[prop] = dom.window.document.body.innerHTML;
}

function hyphenate_doclet(doclet) {
hyphenate_prop(doclet, 'classdoc');
hyphenate_prop(doclet, 'description');
for (const param of doclet.params || []) {
hyphenate_prop(param, 'description');
}
for (const prop of doclet.properties || []) {
hyphenate_prop(prop, 'description');
}
for (const ret of doclet.returns || []) {
hyphenate_prop(ret, 'description');
}
}

/**
@param {TAFFY} taffyData See <http://taffydb.com/>.
@param {object} opts
Expand Down Expand Up @@ -536,8 +569,10 @@ exports.publish = function(taffyData, opts, tutorials) {
doclet.longname = doclet.longname.replace(/^'(.*)'$/, '$1');
}
}
}
doclet.attribs = '';
}
doclet.attribs = '';

hyphenate_doclet(doclet);

if (doclet.examples) {
doclet.examples = doclet.examples.map(function(example) {
Expand Down
1 change: 1 addition & 0 deletions static/styles/jsdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ article .description a {
p, ul, ol, blockquote {
margin-bottom: 1em;
line-height: 160%;
text-align: justify;
}

h1, h2, h3, h4, h5, h6 {
Expand Down