Use Prettier for JS files (#3913)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
16
docs/templates/helpers.js
vendored
16
docs/templates/helpers.js
vendored
@ -2,26 +2,26 @@ const { version } = require('../../package.json');
|
||||
|
||||
module.exports['oz-version'] = () => version;
|
||||
|
||||
module.exports['readme-path'] = (opts) => {
|
||||
module.exports['readme-path'] = opts => {
|
||||
return 'contracts/' + opts.data.root.id.replace(/\.adoc$/, '') + '/README.adoc';
|
||||
};
|
||||
|
||||
module.exports.names = (params) => params.map(p => p.name).join(', ');
|
||||
module.exports.names = params => params.map(p => p.name).join(', ');
|
||||
|
||||
module.exports['typed-params'] = (params) => {
|
||||
module.exports['typed-params'] = params => {
|
||||
return params.map(p => `${p.type}${p.name ? ' ' + p.name : ''}`).join(', ');
|
||||
};
|
||||
|
||||
const slug = module.exports.slug = (str) => {
|
||||
const slug = (module.exports.slug = str => {
|
||||
if (str === undefined) {
|
||||
throw new Error('Missing argument');
|
||||
}
|
||||
return str.replace(/\W/g, '-');
|
||||
};
|
||||
});
|
||||
|
||||
const linksCache = new WeakMap();
|
||||
|
||||
function getAllLinks (items) {
|
||||
function getAllLinks(items) {
|
||||
if (linksCache.has(items)) {
|
||||
return linksCache.get(items);
|
||||
}
|
||||
@ -34,11 +34,11 @@ function getAllLinks (items) {
|
||||
return res;
|
||||
}
|
||||
|
||||
module.exports['with-prelude'] = (opts) => {
|
||||
module.exports['with-prelude'] = opts => {
|
||||
const links = getAllLinks(opts.data.site.items);
|
||||
const contents = opts.fn();
|
||||
const neededLinks = contents
|
||||
.match(/\{[-._a-z0-9]+\}/ig)
|
||||
.match(/\{[-._a-z0-9]+\}/gi)
|
||||
.map(m => m.replace(/^\{(.+)\}$/, '$1'))
|
||||
.filter(k => k in links);
|
||||
const prelude = neededLinks.map(k => `:${k}: ${links[k]}`).join('\n');
|
||||
|
||||
Reference in New Issue
Block a user