當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript remark類代碼示例

本文整理匯總了TypeScript中remark的典型用法代碼示例。如果您正苦於以下問題:TypeScript remark類的具體用法?TypeScript remark怎麽用?TypeScript remark使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了remark類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: remark

    indexArray.forEach(element => {
        let tutData = { link: element["file"] };

        let tutFile = path.resolve(tutFolder, element["file"]);
        let tutFileText = fs.readFileSync(tutFile, "utf8");
        let tutMD = remark().use(frontMatter, ["yaml"]).parse(tutFileText);

        let metadata = getDocMetadata(tutMD);

        if (metadata["Level"]){
            tutData["level"] = metadata["Level"];
        } else {
            tutData["level"] = "";
        }

        let briefDesc = getFirstParagraph(tutMD);

        let briefDescText = remark()
        .use(frontMatter, {type: 'yaml', fence: '---'})
        .data("settings", {paddedTable: false, gfm: false})
        .stringify(briefDesc);

        tutData["briefDesc"] = briefDescText;

        let title = getFirstHeading(tutMD);

        let titleText = remark()
        .use(frontMatter, {type: 'yaml', fence: '---'})
        .data("settings", {paddedTable: false, gfm: false})
        .stringify(title.children[0]);

        tutData["title"] = titleText;

        result.tuts.push(tutData);
    });
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:35,代碼來源:tutorialIndex.ts

示例2: remark

        .then((response) => {
            if (!response['data']) {
                console.log(JSON.stringify(response));
            } else {
                //console.log(template(response['data']));
                let newSection = remark().parse(template(response['data'])).children;

                replaceZone(indexMD, libName, (start, _oldZone, end) => {
                    newSection.unshift(start);
                    newSection.push(end);
                    return newSection;
                });

                let outText = remark()
                .use(frontMatter, {type: 'yaml', fence: '---'})
                .data("settings", {paddedTable: false, gfm: false})
                .stringify(indexMD);

                fs.writeFileSync(indexFilePath, outText);
            }
        });
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:21,代碼來源:gqIndex.ts

示例3: updateFile

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);
    */

    let className = ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
    let classTypeMatch = className.match(/component|directive|service/i);
    let compData = aggData.classInfo[className];

    if (classTypeMatch && compData) {
        let classType = classTypeMatch[0].toLowerCase();

        // Copy docs back from the .md file when the JSDocs are empty.
        let inputMD = getPropDocsFromMD(tree, "Properties", 3);
        let outputMD = getPropDocsFromMD(tree, "Events", 2);
        updatePropDocsFromMD(compData, inputMD, outputMD, errorMessages);

        if (classType === "service") {
            let methodMD = getMethodDocsFromMD(tree);
            updateMethodDocsFromMD(compData, methodMD, errorMessages);
        }

        let templateName = path.resolve(templateFolder, classType + ".ejs");
        let templateSource = fs.readFileSync(templateName, "utf8");
        let template = ejs.compile(templateSource);

        let mdText = template(compData);
        mdText = mdText.replace(/^ +\|/mg, "|");

        let newSection = remark().parse(mdText.trim()).children;

        replaceSection(tree, "Class members", (before, section, after) => {
            newSection.unshift(before);
            newSection.push(after);
            return newSection;
        });

        compData.errors.forEach(err => {
            errorMessages.push(err);
        })
    }

    return true;
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:52,代碼來源:tsInfo.ts

示例4: aggPhase

function aggPhase(aggData) {
    let indexDocData = getIndexDocData();

    let templateName = path.resolve(templateFolder, "tutIndex.ejs");
    let templateSource = fs.readFileSync(templateName, "utf8");
    let template = ejs.compile(templateSource);

    let mdText = template(indexDocData);
    mdText = mdText.replace(/^ +\|/mg, "|");

    let newSection = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;

    let tutIndexFile = path.resolve(tutFolder, "README.md");
    let tutIndexText = fs.readFileSync(tutIndexFile, "utf8");
    let tutIndexMD = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(tutIndexText);

    replaceSection(tutIndexMD, "Tutorials", (before, section, after) => {
        newSection.unshift(before);
        newSection.push(after);
        return newSection;
    });

    fs.writeFileSync(tutIndexFile, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false, gfm: false}).stringify(tutIndexMD));
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:24,代碼來源:tutorialIndex.ts

示例5: getDocReviewDate

function getDocReviewDate(docFileName) {
  let mdFilePath = path.resolve(docsFolderPath, docFileName);

  let mdText = fs.readFileSync(mdFilePath);
  let tree = remark().use(frontMatter, ["yaml"]).parse(mdText);

  let lastReviewDate = moment(adf20StartDate);

  if (tree.children[0].type == "yaml") {
    let metadata = yaml.load(tree.children[0].value);

    if (metadata["Last reviewed"])
      lastReviewDate = moment(metadata["Last reviewed"]);
  }

  return lastReviewDate;
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:17,代碼來源:reviewChecker.ts

示例6: processDocs

export function processDocs(mdCache, aggData, _errorMessages) {
    let docset: MQ.Docset = new MQ.Docset(mdCache);

    let templateFilePath = path.resolve(__dirname, '..', 'templates', 'gqIndex.ejs');
    let templateSource = fs.readFileSync(templateFilePath, 'utf8');
    let template = ejs.compile(templateSource);

    let indexFilePath = path.resolve(aggData['rootFolder'], 'docs', 'README.md');
    let indexFileText = fs.readFileSync(indexFilePath, 'utf8');
    let indexMD = remark()
    .use(frontMatter, ["yaml"])
    .parse(indexFileText);

    let schema = buildSchema(MQ.schema);

    libNamesList.forEach(libName => {
        graphql(schema, query, docset, null, {'libName': libName})
        .then((response) => {
            if (!response['data']) {
                console.log(JSON.stringify(response));
            } else {
                //console.log(template(response['data']));
                let newSection = remark().parse(template(response['data'])).children;

                replaceZone(indexMD, libName, (start, _oldZone, end) => {
                    newSection.unshift(start);
                    newSection.push(end);
                    return newSection;
                });

                let outText = remark()
                .use(frontMatter, {type: 'yaml', fence: '---'})
                .data("settings", {paddedTable: false, gfm: false})
                .stringify(indexMD);

                fs.writeFileSync(indexFilePath, outText);
            }
        });
    });

    
}
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:42,代碼來源:gqIndex.ts

示例7: remark

import * as fs from 'fs';
import * as path from 'path';

import { graphql, buildSchema } from 'graphql';

import * as remark from 'remark';
import * as frontMatter from 'remark-frontmatter';
import { MDAST } from 'mdast';
import * as removePosInfo from 'unist-util-remove-position';

import * as MQ from './mqDefs';

let docFilePath = path.resolve('..', '..', 'docs', 'core', 'about.component.md');
let docSrc = fs.readFileSync(docFilePath, 'utf8');

let tree: MDAST.Root = remark()
.use(frontMatter, ["yaml"])
.parse(docSrc);

tree = removePosInfo(tree);

//console.log(JSON.stringify(tree));

let schema = buildSchema(MQ.schema);

let root = {
    document: () => new MQ.Root(tree)
};


let query = `
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:31,代碼來源:remarkGraphQl.ts


注:本文中的remark類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。