From d67f728b209d691e1332aaae1ce827729b896a9f Mon Sep 17 00:00:00 2001 From: Jay Traband Date: Tue, 11 Aug 2015 11:55:22 -0700 Subject: [PATCH] clean up regionExtractor to hoist nullLine pattern, add examplesDir to xref info --- public/doc-shredder/regionExtractor.js | 9 +- public/doc-shredder/shredMapProcessor.js | 22 +++- .../doc-shredder/test/xref-frag-to-jade.html | 16 ++- .../doc-shredder/test/xref-jade-to-frag.html | 4 +- public/doc-shredder/test/xref-jade.json | 101 ++++++++++-------- public/docs/xref-frag-to-jade.html | 12 +-- public/docs/xref-jade-to-frag.html | 2 +- public/docs/xref-jade.json | 7 +- 8 files changed, 108 insertions(+), 65 deletions(-) diff --git a/public/doc-shredder/regionExtractor.js b/public/doc-shredder/regionExtractor.js index e52535887d..1b5647bf41 100644 --- a/public/doc-shredder/regionExtractor.js +++ b/public/doc-shredder/regionExtractor.js @@ -1,4 +1,8 @@ module.exports = function regionExtractor() { + + var nullLine = '###'; + var nullLinePattern = new RegExp(nullLine + '\n', 'g'); + // split out each fragment in {content} into a separate doc // a fragment is a section of text surrounded by // 1) In front: a comment marker followed by '#docregion' followed by an optional region name. For example: @@ -12,7 +16,6 @@ module.exports = function regionExtractor() { var docs = []; var docStack = []; var doc = null; - var nullLine = '###'; lines.forEach(function(line, ix) { if (isCommentLine(line, commentPrefixes)) { @@ -29,7 +32,7 @@ module.exports = function regionExtractor() { } }); - var rx = new RegExp(nullLine + '\n', 'g'); + docs.forEach(function(doc) { var content; if (doc.endIx) { @@ -38,7 +41,7 @@ module.exports = function regionExtractor() { content = lines.slice(doc.startIx + 1).join('\n'); } // eliminate all #docregion lines - content = content.replace(rx, ''); + content = content.replace(nullLinePattern, ''); if (content.substr(-3) === nullLine) { content = content.substr(0, content.length-3); } diff --git a/public/doc-shredder/shredMapProcessor.js b/public/doc-shredder/shredMapProcessor.js index 8446df721c..921d6ef75f 100644 --- a/public/doc-shredder/shredMapProcessor.js +++ b/public/doc-shredder/shredMapProcessor.js @@ -15,12 +15,15 @@ module.exports = function shredMapProcessor(log) { var options = this.options; var jadeToFragMap = {}; var fragToJadeMap = {}; + docs.forEach(function(doc) { var jadePath = path.join(options.jadeDir, doc.fileInfo.relativePath); var fragInfos = doc.fragPaths.map(function(fragPath) { - fragPath = path.join(options.fragmentsDir, fragPath) + '.md'; - var fullPath = path.join(options.basePath, fragPath); - var fragInfo = { fragPath: fragPath, exists: fs.existsSync(fullPath) }; + var relativeFragPath = path.join(options.fragmentsDir, fragPath) + '.md'; + var fullPath = path.join(options.basePath, relativeFragPath); + var examplePath = getExampleName(fragPath); + var relativeExamplePath = path.join(options.examplesDir, examplePath); + var fragInfo = { fragPath: relativeFragPath, examplePath: relativeExamplePath, exists: fs.existsSync(fullPath) }; if (fragInfo.exists) { var jadePaths = fragToJadeMap[fragInfo]; if (!jadePaths) { @@ -54,4 +57,15 @@ module.exports = function shredMapProcessor(log) { return newDocs; } }; -}; \ No newline at end of file +}; + +function getExampleName(fragPath) { + // pattern to isolate base fileName and extension from fragment name + var rx = /(.*)\-(.*)\.(.s)/; + var r = rx.exec(fragPath); + if (r) { + return r[1] + '.' + r[3]; + } else { + return fragPath; + } +} \ No newline at end of file diff --git a/public/doc-shredder/test/xref-frag-to-jade.html b/public/doc-shredder/test/xref-frag-to-jade.html index cc7fbd1d96..5a8bbd396c 100644 --- a/public/doc-shredder/test/xref-frag-to-jade.html +++ b/public/doc-shredder/test/xref-frag-to-jade.html @@ -4,7 +4,7 @@
  1. - Fragment file: test_fragments/gettingstarted/ts/index.html.md + Fragment file: gettingstarted/ts/index.html

    Jade files

    • test_jade/guides/setupAlt2.jade
    • @@ -12,7 +12,7 @@
    • - Fragment file: test_fragments/gettingstarted/js/index.html.md + Fragment file: gettingstarted/js/index.html

      Jade files

      • test_jade/setupAlt.jade
      • @@ -20,7 +20,7 @@
      • - Fragment file: test_fragments/gettingstarted/ts/main.ts.md + Fragment file: gettingstarted/ts/main.ts

        Jade files

        • test_jade/setupAlt.jade
        • @@ -28,7 +28,15 @@
        • - Fragment file: test_fragments/gettingstarted/ts/main-import.ts.md + Fragment file: gettingstarted/js/main.js +

          Jade files

          +
            +
          • test_jade/guides/setupAlt2.jade
          • +
          +
          +
        • +
        • + Fragment file: gettingstarted/ts/main-import.ts

          Jade files

          • test_jade/setupAlt.jade
          • diff --git a/public/doc-shredder/test/xref-jade-to-frag.html b/public/doc-shredder/test/xref-jade-to-frag.html index 7da870ff03..86e963f277 100644 --- a/public/doc-shredder/test/xref-jade-to-frag.html +++ b/public/doc-shredder/test/xref-jade-to-frag.html @@ -6,14 +6,14 @@
          • Jade file: test_jade/guides/setupAlt2.jade

            Fragment files

            -
            • test_fragments/gettingstarted/ts/index.html.md
            • test_fragments/gettingstarted/js/index.html.md
            • test_fragments/gettingstarted/ts/main.ts.md
            • *** NOT FOUND*** : test_fragments/gettingstarted/ js/main.js.md
            • test_fragments/gettingstarted/ts/main-import.ts.md
            • +
              • test_fragments/gettingstarted/ts/index.html.md
              • test_fragments/gettingstarted/js/index.html.md
              • test_fragments/gettingstarted/ts/main.ts.md
              • test_fragments/gettingstarted/js/main.js.md
              • test_fragments/gettingstarted/ts/main-import.ts.md

            • Jade file: test_jade/setupAlt.jade

              Fragment files

              -
              • *** NOT FOUND*** : test_fragments/gettingstarted/ts/index2.html.md
              • test_fragments/gettingstarted/js/index.html.md
              • test_fragments/gettingstarted/ts/main.ts.md
              • *** NOT FOUND*** : test_fragments/gettingstarted/ js/main2.js.md
              • test_fragments/gettingstarted/ts/main-import.ts.md
              • +
                • *** NOT FOUND*** : test_fragments/gettingstarted/ts/index2.html.md
                • test_fragments/gettingstarted/js/index.html.md
                • test_fragments/gettingstarted/ts/main.ts.md
                • *** NOT FOUND*** : test_fragments/gettingstarted/js/main2.js.md
                • test_fragments/gettingstarted/ts/main-import.ts.md

                diff --git a/public/doc-shredder/test/xref-jade.json b/public/doc-shredder/test/xref-jade.json index 9a5629090f..04c056e012 100644 --- a/public/doc-shredder/test/xref-jade.json +++ b/public/doc-shredder/test/xref-jade.json @@ -1,46 +1,59 @@ { - "test_jade/guides/setupAlt2.jade": [ - { - "fragPath": "test_fragments/gettingstarted/ts/index.html.md", - "exists": true - }, - { - "fragPath": "test_fragments/gettingstarted/js/index.html.md", - "exists": true - }, - { - "fragPath": "test_fragments/gettingstarted/ts/main.ts.md", - "exists": true - }, - { - "fragPath": "test_fragments/gettingstarted/ js/main.js.md", - "exists": false - }, - { - "fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md", - "exists": true - } - ], - "test_jade/setupAlt.jade": [ - { - "fragPath": "test_fragments/gettingstarted/ts/index2.html.md", - "exists": false - }, - { - "fragPath": "test_fragments/gettingstarted/js/index.html.md", - "exists": true - }, - { - "fragPath": "test_fragments/gettingstarted/ts/main.ts.md", - "exists": true - }, - { - "fragPath": "test_fragments/gettingstarted/ js/main2.js.md", - "exists": false - }, - { - "fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md", - "exists": true - } - ] + "basePath": "c:/GitHub/angular.io.ideablade/public/doc-shredder/test", + "jadeToFragMap": { + "test_jade/guides/setupAlt2.jade": [ + { + "fragPath": "test_fragments/gettingstarted/ts/index.html.md", + "examplePath": "test_source/gettingstarted/ts/index.html", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/js/index.html.md", + "examplePath": "test_source/gettingstarted/js/index.html", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/ts/main.ts.md", + "examplePath": "test_source/gettingstarted/ts/main.ts", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/js/main.js.md", + "examplePath": "test_source/gettingstarted/js/main.js", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md", + "examplePath": "test_source/gettingstarted/ts/main.ts", + "exists": true + } + ], + "test_jade/setupAlt.jade": [ + { + "fragPath": "test_fragments/gettingstarted/ts/index2.html.md", + "examplePath": "test_source/gettingstarted/ts/index2.html", + "exists": false + }, + { + "fragPath": "test_fragments/gettingstarted/js/index.html.md", + "examplePath": "test_source/gettingstarted/js/index.html", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/ts/main.ts.md", + "examplePath": "test_source/gettingstarted/ts/main.ts", + "exists": true + }, + { + "fragPath": "test_fragments/gettingstarted/js/main2.js.md", + "examplePath": "test_source/gettingstarted/js/main2.js", + "exists": false + }, + { + "fragPath": "test_fragments/gettingstarted/ts/main-import.ts.md", + "examplePath": "test_source/gettingstarted/ts/main.ts", + "exists": true + } + ] + } } \ No newline at end of file diff --git a/public/docs/xref-frag-to-jade.html b/public/docs/xref-frag-to-jade.html index cd7000bff7..5d7ae4dbdc 100644 --- a/public/docs/xref-frag-to-jade.html +++ b/public/docs/xref-frag-to-jade.html @@ -1,10 +1,10 @@

                Frament path to jade path cross reference report -

                Base path: c:\GitHub\angular.io.ideablade\public\docs

                +

                Base path: C:\GitHub\angular.io.ideablade\public\docs

                1. - Fragment file: _fragments/gettingstarted/ts/index.html.md + Fragment file: gettingstarted/ts/index.html

                  Jade files

                  • js/latest/guide/setupAlt.jade
                  • @@ -12,7 +12,7 @@
                  • - Fragment file: _fragments/gettingstarted/js/index.html.md + Fragment file: gettingstarted/js/index.html

                    Jade files

                    • js/latest/guide/setupAlt.jade
                    • @@ -20,7 +20,7 @@
                    • - Fragment file: _fragments/gettingstarted/ts/main.ts.md + Fragment file: gettingstarted/ts/main.ts

                      Jade files

                      • js/latest/guide/setupAlt.jade
                      • @@ -28,7 +28,7 @@
                      • - Fragment file: _fragments/gettingstarted/js/main.js.md + Fragment file: gettingstarted/js/main.js

                        Jade files

                        • js/latest/guide/setupAlt.jade
                        • @@ -36,7 +36,7 @@
                        • - Fragment file: _fragments/gettingstarted/ts/main-import.ts.md + Fragment file: gettingstarted/ts/main-import.ts

                          Jade files

                          • js/latest/guide/setupAlt.jade
                          • diff --git a/public/docs/xref-jade-to-frag.html b/public/docs/xref-jade-to-frag.html index 1d7bf4dce0..9a8b83e1b3 100644 --- a/public/docs/xref-jade-to-frag.html +++ b/public/docs/xref-jade-to-frag.html @@ -1,6 +1,6 @@

                            Jade path to fragment path cross reference report -

                            Base path: c:\GitHub\angular.io.ideablade\public\docs

                            +

                            Base path: C:\GitHub\angular.io.ideablade\public\docs

                            1. diff --git a/public/docs/xref-jade.json b/public/docs/xref-jade.json index d5cd12908b..d122903e4e 100644 --- a/public/docs/xref-jade.json +++ b/public/docs/xref-jade.json @@ -1,25 +1,30 @@ { - "basePath": "c:\\GitHub\\angular.io.ideablade\\public\\docs", + "basePath": "C:\\GitHub\\angular.io.ideablade\\public\\docs", "jadeToFragMap": { "js/latest/guide/setupAlt.jade": [ { "fragPath": "_fragments/gettingstarted/ts/index.html.md", + "examplePath": "_examples/gettingstarted/ts/index.html", "exists": true }, { "fragPath": "_fragments/gettingstarted/js/index.html.md", + "examplePath": "_examples/gettingstarted/js/index.html", "exists": true }, { "fragPath": "_fragments/gettingstarted/ts/main.ts.md", + "examplePath": "_examples/gettingstarted/ts/main.ts", "exists": true }, { "fragPath": "_fragments/gettingstarted/js/main.js.md", + "examplePath": "_examples/gettingstarted/js/main.js", "exists": true }, { "fragPath": "_fragments/gettingstarted/ts/main-import.ts.md", + "examplePath": "_examples/gettingstarted/ts/main.ts", "exists": true } ]