Пример #1
0
                .use(() => (tree) => {
                  heading(tree, /Contributors/, (start, nodes, end) => {
                    const { children } = remark()
                      .use(remarkPreset)
                      .parse(transformedContributors);

                    return [
                      start,
                      u(
                        'html',
                        '<!-- This section was automatically generated. -->'
                      ),
                      ...children,
                      end,
                    ];
                  });
                })
Пример #2
0
/*
function initPhase(aggData) {
    nameExceptions = aggData.config.typeNameExceptions;

    let app = new Application({
        exclude: excludePatterns,
        ignoreCompilerErrors: true,
        experimentalDecorators: true,
        tsconfig: "tsconfig.json"
    });

    let sources = app.expandInputFiles(libFolders.map(folder => {
        return path.resolve("lib", folder);
    }));

    aggData.projData = app.convert(sources);
}
*/
function updateFile(tree, pathname, aggData, errorMessages) {
    /*
    let compName = angNameToClassName(path.basename(pathname, ".md"));
    let classRef = aggData.projData.findReflectionByName(compName);

    if (!classRef) {
        // A doc file with no corresponding class (eg, Document Library Model).
        return false;
    }

    let compData = new ComponentInfo(classRef);
    */
    var className = ngHelpers_1.ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
    var classTypeMatch = className.match(/component|directive|service/i);
    var compData = aggData.classInfo[className];
    if (classTypeMatch && compData) {
        var classType = classTypeMatch[0].toLowerCase();
        // Copy docs back from the .md file when the JSDocs are empty.
        var inputMD = getPropDocsFromMD(tree, "Properties", 3);
        var outputMD = getPropDocsFromMD(tree, "Events", 2);
        updatePropDocsFromMD(compData, inputMD, outputMD, errorMessages);
        if (classType === "service") {
            var methodMD = getMethodDocsFromMD(tree);
            updateMethodDocsFromMD(compData, methodMD, errorMessages);
        }
        var templateName = path.resolve(templateFolder, classType + ".ejs");
        var templateSource = fs.readFileSync(templateName, "utf8");
        var template = ejs.compile(templateSource);
        var mdText = template(compData);
        mdText = mdText.replace(/^ +\|/mg, "|");
        var newSection_1 = remark().parse(mdText.trim()).children;
        replaceSection(tree, "Class members", function (before, section, after) {
            newSection_1.unshift(before);
            newSection_1.push(after);
            return newSection_1;
        });
        compData.errors.forEach(function (err) {
            errorMessages.push(err);
        });
    }
    return true;
}
Пример #3
0
    return tree => {
        heading(tree, 'Property support', (start, nodes, end) => {
            const done = completed.length;
            const total = properties.length;
            const children = [{
                type: 'paragraph',
                children: [{
                    type: 'text',
                    value: `We support ${done} of ${total} CSS properties (${percentage(done, total)}%).`,
                }],
            }, {
                type: 'list',
                ordered: false,
                children: completed.map(createItem),
            }];

            const node = {
                type: 'root',
                children,
            };

            return [start, node, end];
        });
    };
Пример #4
0
 .use(() => (tree) => {
   heading(
     tree,
     /^What optimisations do you support\?/i,
     (start, nodes, end) => {
       return [
         start,
         u(
           'html',
           '<!-- This section is automatically generated. -->'
         ),
         u('paragraph', [
           u(
             'text',
             `The optimisations are different depending on which preset cssnano is configured with; with the default preset, we offer safe transforms only.`
           ),
         ]),
         optimisationsTable(presets, plugins),
         u('paragraph', [
           u('text', 'You can read more about presets in our '),
           u('link', { url: '/guides/presets/' }, [
             u('text', 'presets guide'),
           ]),
           u('text', '.'),
         ]),
         end,
       ];
     }
   );
 })
Пример #5
0
    return function (tree) {
        heading(tree, /^licen[cs]e$/i, function (start, nodes, end) {
            var children = [];
            var url;
            var node;
            var parent;

            node = {
                'type': 'paragraph',
                'children': children
            };

            if (!settings.file) {
                parent = node;
            } else {
                parent = {
                    'type': 'link',
                    'url': settings.file,
                    'children': []
                };

                children.push(parent);
            }

            parent.children.push({
                'type': 'text',
                'value': settings.license
            });

            children.push({
                'type': 'text',
                'value': ' © '
            });

            if (!settings.url) {
                parent = node;
            } else {
                url = settings.url;

                if (
                    url.slice(0, HTTP_PROTOCOL.length) !== HTTP_PROTOCOL &&
                    url.slice(0, HTTPS_PROTOCOL.length) !== HTTPS_PROTOCOL
                ) {
                    url = HTTP_PROTOCOL + url;
                }

                parent = {
                    'type': 'link',
                    'url': url,
                    'children': []
                };

                children.push(parent);
            }

            parent.children.push({
                'type': 'text',
                'value': settings.name
            });

            return [start, node, end];
        });
    };