cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblot...@apache.org
Subject docs commit: Porting two Python scripts to JS.
Date Tue, 11 Aug 2015 04:32:24 GMT
Repository: cordova-docs
Updated Branches:
  refs/heads/cordova-website e0ff4bef1 -> eff777a8f


Porting two Python scripts to JS.


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/eff777a8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/eff777a8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/eff777a8

Branch: refs/heads/cordova-website
Commit: eff777a8feaf684837950c585ee713533c9f374d
Parents: e0ff4be
Author: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Authored: Mon Aug 10 21:32:18 2015 -0700
Committer: Dmitry Blotsky <dmitry.blotsky@gmail.com>
Committed: Mon Aug 10 21:32:18 2015 -0700

----------------------------------------------------------------------
 gulpfile.js                |  4 +--
 package.json               |  1 +
 tools/bin/all_toc.py       | 17 ++++++++++
 tools/bin/count_files.py   | 17 ++++++++++
 tools/bin/fix_license.py   | 17 ++++++++++
 tools/bin/gen_defaults.js  | 74 +++++++++++++++++++++++++++++++++++++++++
 tools/bin/gen_defaults.py  | 17 ++++++++++
 tools/bin/gen_languages.js | 66 ++++++++++++++++++++++++++++++++++++
 tools/bin/gen_languages.py | 17 ++++++++++
 tools/bin/merge_files.py   | 17 ++++++++++
 tools/bin/util.js          | 66 ++++++++++++++++++++++++++++++++++++
 tools/bin/util.py          | 17 ++++++++++
 12 files changed, 328 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/gulpfile.js
----------------------------------------------------------------------
diff --git a/gulpfile.js b/gulpfile.js
index 6764c47..1a65fad 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -119,9 +119,9 @@ gulp.task("serve", function (done) {
 });
 
 gulp.task("configs", function (done) {
-    execPiped("python", [bin("gen_defaults.py"), DOCS_DIR], DEFAULTS_FILE)
+    execPiped("node", [bin("gen_defaults.py"), DOCS_DIR], DEFAULTS_FILE)
         .pipe(gulp.dest("."));
-    execPiped("python", [bin("gen_languages.py"), DOCS_DIR], LANGUAGES_FILE)
+    execPiped("node", [bin("gen_languages.js"), DOCS_DIR], LANGUAGES_FILE)
         .pipe(gulp.dest("."));
     exec("python", [bin("all_toc.py"), DOCS_DIR, DATA_DIR], done);
 });

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index acb3de8..91f10e5 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
   "devDependencies": {
     "colors": "^1.0.3",
     "diff": "^1.2.0",
+    "js-yaml": "^3.3.1",
     "jshint": "^2.5.8",
     "mocha": "^1.21.4"
   },

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/all_toc.py
----------------------------------------------------------------------
diff --git a/tools/bin/all_toc.py b/tools/bin/all_toc.py
index 6aefc28..2b8ceb0 100644
--- a/tools/bin/all_toc.py
+++ b/tools/bin/all_toc.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import os
 import sys
 import argparse

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/count_files.py
----------------------------------------------------------------------
diff --git a/tools/bin/count_files.py b/tools/bin/count_files.py
index cac89ea..52758bd 100755
--- a/tools/bin/count_files.py
+++ b/tools/bin/count_files.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import os
 import sys
 

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/fix_license.py
----------------------------------------------------------------------
diff --git a/tools/bin/fix_license.py b/tools/bin/fix_license.py
index 5b31935..d220b93 100644
--- a/tools/bin/fix_license.py
+++ b/tools/bin/fix_license.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 # -*- coding: utf-8 -*-
 
 import os

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/gen_defaults.js
----------------------------------------------------------------------
diff --git a/tools/bin/gen_defaults.js b/tools/bin/gen_defaults.js
new file mode 100644
index 0000000..c8b196b
--- /dev/null
+++ b/tools/bin/gen_defaults.js
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+"use strict";
+
+var fs   = require("fs");
+var path = require("path");
+var yaml = require("js-yaml");
+
+var util = require("./util");
+
+function main () {
+
+    var rootDir = process.argv[2];
+    var config  = {"defaults": []};
+
+    if (!rootDir) {
+        console.error("Please specify a directory from which to generate.");
+        process.exit(1);
+    }
+
+    // go through directory that contains all languages
+    util.listdirsSync(rootDir).forEach(function (langName) {
+
+        var langPath = path.join(rootDir, langName);
+
+        // define language scope
+        config.defaults.push({
+            scope: {
+                path: "docs/" + langName
+            },
+            values: {
+                language: langName,
+                layout:   "docs-" + langName
+            }
+        });
+
+        util.listdirsSync(langPath).forEach(function (versionName) {
+
+            var manual    = util.manualTocfileName(langName, versionName);
+            var generated = util.generatedTocfileName(langName, versionName);
+
+            // define version scope
+            config.defaults.push({
+                scope: {
+                    path: "docs/" + langName + "/" + versionName
+                },
+                values: {
+                    version:       versionName,
+                    manual_toc:    manual.replace(".yml", ""),
+                    generated_toc: generated.replace(".yml", "")
+                }
+            });
+        });
+    });
+
+    console.log(yaml.dump(config));
+}
+
+main();

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/gen_defaults.py
----------------------------------------------------------------------
diff --git a/tools/bin/gen_defaults.py b/tools/bin/gen_defaults.py
index 99c30a3..3d1a85b 100644
--- a/tools/bin/gen_defaults.py
+++ b/tools/bin/gen_defaults.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import os
 import sys
 import yaml

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/gen_languages.js
----------------------------------------------------------------------
diff --git a/tools/bin/gen_languages.js b/tools/bin/gen_languages.js
new file mode 100755
index 0000000..0ee27cf
--- /dev/null
+++ b/tools/bin/gen_languages.js
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+"use strict";
+
+var fs   = require("fs");
+var path = require("path");
+var yaml = require("js-yaml");
+
+var util = require("./util");
+
+// constants
+var LANGUAGE_MAP = {
+    "de": "Deutsch",
+    "en": "English",
+    "es": "Español",
+    "fr": "Français",
+    "it": "Italiano",
+    "ja": "日本語",
+    "ko": "한국어",
+    "pl": "Polski",
+    "ru": "Русский",
+    "sl": "Slovene",
+    "zh": "汉语",
+};
+
+function main () {
+
+    var rootDir = process.argv[2];
+    var config = {};
+
+    if (!rootDir) {
+        console.error("Please specify a directory from which to generate.");
+        process.exit(1);
+    }
+
+    // go through directory that contains all languages
+    util.listdirsSync(rootDir).forEach(function (langId) {
+
+        var langPath     = path.join(rootDir, langId);
+        var versionNames = util.listdirsSync(langPath);
+
+        config[langId] = {
+            'name':     LANGUAGE_MAP[langId],
+            'versions': versionNames
+        };
+    });
+
+    console.log(yaml.dump(config));
+}
+
+main();

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/gen_languages.py
----------------------------------------------------------------------
diff --git a/tools/bin/gen_languages.py b/tools/bin/gen_languages.py
index ccf5932..4ecf07f 100644
--- a/tools/bin/gen_languages.py
+++ b/tools/bin/gen_languages.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 # -*- coding: utf-8 -*-
 
 import os

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/merge_files.py
----------------------------------------------------------------------
diff --git a/tools/bin/merge_files.py b/tools/bin/merge_files.py
index dbd45fb..3ef8fc8 100644
--- a/tools/bin/merge_files.py
+++ b/tools/bin/merge_files.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import os
 import sys
 import json

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/util.js
----------------------------------------------------------------------
diff --git a/tools/bin/util.js b/tools/bin/util.js
new file mode 100644
index 0000000..9f39974
--- /dev/null
+++ b/tools/bin/util.js
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+"use strict";
+
+module.exports = function () {
+
+    var fs   = require("fs");
+    var path = require("path");
+
+    return {
+
+        stripFrontMatter: function(text) {
+
+            var marker = "---";
+
+            var firstMarker = text.indexOf(marker);
+            if (firstMarker === (-1)) {
+                return text;
+            }
+
+            var secondMarker = text.indexOf(marker, firstMarker + marker.length);
+            var start        = secondMarker + marker.length;
+
+            return text.slice(start);
+        },
+
+        listdirsSync: function (root) {
+            return fs.readdirSync(root).filter(function(fileName) {
+                return fs.statSync(path.join(root, fileName)).isDirectory();
+            });
+        },
+
+        tocfileName: function(language, version, suffix) {
+            var versionSlug = version.replace(/\./g, "-");
+            if (suffix) {
+                suffix = "-" + suffix;
+            } else {
+                suffix = "";
+            }
+            return language + "-" + versionSlug + suffix + ".yml";
+        },
+
+        manualTocfileName: function(language, version) {
+            return module.exports.tocfileName(language, version, "manual");
+        },
+
+        generatedTocfileName: function(language, version) {
+            return module.exports.tocfileName(language, version, "generated");
+        },
+    }
+}();

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/eff777a8/tools/bin/util.py
----------------------------------------------------------------------
diff --git a/tools/bin/util.py b/tools/bin/util.py
index 207c985..37b1936 100644
--- a/tools/bin/util.py
+++ b/tools/bin/util.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import os
 import errno
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message