You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by dblotsky <gi...@git.apache.org> on 2016/02/23 00:17:01 UTC

[GitHub] cordova-docs pull request: Docs fetching improvements

GitHub user dblotsky opened a pull request:

    https://github.com/apache/cordova-docs/pull/514

    Docs fetching improvements

    - Adding comments in `fetched-files.yml`
    - Refactoring `fetch_docs.js`
    - Removing `pluginapis.md` and placing plugins into the ToC
    - Adding redirect for `pluginapis.md`

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MSOpenTech/cordova-docs plugins-in-toc

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-docs/pull/514.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #514
    
----
commit a60b5c34f55542d3e47e5e90dfccc293112cf886
Author: Dmitry Blotsky <dm...@gmail.com>
Date:   2016-02-20T02:29:20Z

    Adding comments in fetched-files.yml. Refactoring fetch_docs.js. Removing pluginapis.md.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on the pull request:

    https://github.com/apache/cordova-docs/pull/514#issuecomment-187542875
  
    LGTM. Good change! My commit depends on this change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on the pull request:

    https://github.com/apache/cordova-docs/pull/514#issuecomment-187433175
  
    @nikhilkh @sarangan12 @riknoll please review when you have a moment,


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53737326
  
    --- Diff: www/_data/toc/de-dev-manual.yml ---
    @@ -1,96 +1,138 @@
     -   name: "Introduction"
         children:
    -        -   name: "Overview"
    -            url: "guide/overview/index.html"
    -#       -   name: "Runtime Architecture"
    -#           url:
    -#       -   name: "Tooling Architecture"
    -#           url:
    +    -   name: "Overview"
    +        url: "guide/overview/index.html"
    +    # -   name: "Runtime Architecture"
    +    #     url:
    +    # -   name: "Tooling Architecture"
    +    #     url:
     -   name: "Create apps"
         children:
    -        -   name: "Create your first app"
    -            url:
    -        -   name: "Platform support"
    -            url: "guide/support/index.html"
    -        -   name: "Develop for platforms"
    -            children:
    -                -   name: "Android"
    -                    url: "guide/platforms/android/index.html"
    -                -   name: "Blackberry 10"
    -                    url: "guide/platforms/blackberry10/home.html"
    -                -   name: "iOS"
    -                    url: "guide/platforms/ios/index.html"
    -                -   name: "Ubuntu"
    -                    url: "guide/platforms/ubuntu/index.html"
    -                -   name: "Windows"
    -                    url: "guide/platforms/win8/index.html"
    -                -   name: "WP8"
    -                    url: "guide/platforms/wp8/home.html"                                                           
    -        -   name: "Manage versions and platforms"
    -            url: "platform_plugin_versioning_ref/index.html"
    -        -   name: "Debug and test"
    -            url:
    -        -   name: "Use icons and splash screens"
    -            url: "config_ref/images.html"
    -        -   name: "Automate Tasks"
    -            url:
    -        -   name: "Store data"
    -            url: "cordova/storage/storage.html"
    -        -   name: "Manage privacy"
    -            url: "guide/appdev/privacy/index.html"
    -        -   name: "Manage security"
    -            url: "guide/appdev/security/index.html"
    -        -   name: "Whitelisting"
    -            url: "guide/appdev/whitelist/index.html"
    -        -   name: "Publish"
    -            url:
    +    # -   name: "Create your first app"
    +    #     url:
    +    -   name: "Platform support"
    +        url: "guide/support/index.html"
    +    -   name: "Develop for platforms"
    +        children:
    +        -   name: "Android"
    +            url: "guide/platforms/android/index.html"
    +        -   name: "Blackberry 10"
    +            url: "guide/platforms/blackberry10/home.html"
    +        -   name: "iOS"
    +            url: "guide/platforms/ios/index.html"
    +        -   name: "Ubuntu"
    +            url: "guide/platforms/ubuntu/index.html"
    +        -   name: "Windows"
    +            url: "guide/platforms/win8/index.html"
    +        -   name: "WP8"
    +            url: "guide/platforms/wp8/home.html"
    +    -   name: "Manage versions and platforms"
    +        url: "platform_plugin_versioning_ref/index.html"
    +    # -   name: "Debug and test"
    +    #     url:
    +    -   name: "Use icons and splash screens"
    +        url: "config_ref/images.html"
    +    # -   name: "Automate Tasks"
    +    #     url:
    +    -   name: "Store data"
    +        url: "cordova/storage/storage.html"
    +    -   name: "Manage privacy"
    +        url: "guide/appdev/privacy/index.html"
    +    -   name: "Manage security"
    +        url: "guide/appdev/security/index.html"
    +    -   name: "Whitelisting"
    +        url: "guide/appdev/whitelist/index.html"
    +    # -   name: "Publish"
    +    #     url:
     -   name: "Create plugins"
         children:
    -        -   name: "Create a plugin"
    -            url: "guide/hybrid/plugins/index.html"
    -        -   name: "Register with NPM"
    -            url:
    -        -   name: "Develop for platforms"
    -            children:
    -                -   name: "Android"
    -                    url: "guide/platforms/android/plugin.html"
    -                -   name: "Blackberry 10"
    -                    url: "guide/platforms/blackberry10/plugin.html"
    -                -   name: "iOS"
    -                    url: "guide/platforms/ios/plugin.html"
    -                -   name: "Windows"
    -                    url: "guide/platforms/win8/plugin.html"
    -                -   name: "WP8"
    -                    url: "guide/platforms/wp8/plugin.html"
    -        -   name: "Use Plugman"
    -            url: "plugin_ref/plugman.html"
    -        -   name: "Debug and test"
    -            url:
    +    -   name: "Create a plugin"
    +        url: "guide/hybrid/plugins/index.html"
    +    # -   name: "Register with NPM"
    +    #     url:
    +    -   name: "Develop for platforms"
    +        children:
    +        -   name: "Android"
    +            url: "guide/platforms/android/plugin.html"
    +        -   name: "Blackberry 10"
    +            url: "guide/platforms/blackberry10/plugin.html"
    +        -   name: "iOS"
    +            url: "guide/platforms/ios/plugin.html"
    +        -   name: "Windows"
    +            url: "guide/platforms/win8/plugin.html"
    +        -   name: "WP8"
    +            url: "guide/platforms/wp8/plugin.html"
    +    -   name: "Use Plugman"
    +        url: "plugin_ref/plugman.html"
    +    # -   name: "Debug and test"
    +    #     url:
     -   name: "Advanced Topics"
         children:
    -        -   name: "Embed Cordova in native apps"
    -            url: "guide/hybrid/webviews/index.html"
    -        -   name: "Pass data from Cordova app to host"
    -            url:
    -        -   name: "Next Steps"
    -            url: "guide/next/index.html"
    +    -   name: "Embed Cordova in native apps"
    +        url: "guide/hybrid/webviews/index.html"
    +    # -   name: "Pass data from Cordova app to host"
    +    #     url:
    +    -   name: "Next Steps"
    +        url: "guide/next/index.html"
     -   name: "Reference"
         children:
    -        -   name: "Config.xml"
    -            url: "config_ref/index.html"
    -        -   name: "Events"
    -            url: "cordova/events/events.html"
    -        -   name: "Plugin APIs"
    -            url: "cordova/plugins/pluginapis.html"
    -        -   name: "CLI"
    -            url: "guide/cli/index.html"
    -        -   name: "Hooks"
    -            url: "guide/appdev/hooks/index.html"
    -        -   name: "Plugin.xml"
    -            url: "plugin_ref/spec.html"
    +    -   name: "Config.xml"
    +        url: "config_ref/index.html"
    +    -   name: "Events"
    +        url: "cordova/events/events.html"
    +    -   name: "Plugin APIs"
    +        children:
    --- End diff --
    
    Changed. I also reduced the padding in the ToC. Perhaps we should prioritize implementing the new ToC design, because it's getting a little unwieldy and the headings with children look really out of place.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53842147
  
    --- Diff: www/_data/fetched-files.yml ---
    @@ -1,153 +1,146 @@
    +# REFERENCE ENTRY:
    +#
    +# -
    +#     src:                                                            # required
    +#         repoName:    "apache/cordova-cli"                           # required
    +#         packageName: "cordova"                                      # if empty: second part of repoName
    +#         commit:      "master"                                       # if empty: latest in NPM
    +#         path:        "relative/path/to/file/in/repo.md"             # if empty: "README.md"
    +#     dest:                                                           # required
    +#         permalink:   "/absolute/path/on/cordova/site/index.html"    # if empty: "/gen/" + packageName + "/"
    +#
    +
     -
         src:
             repoName: "apache/cordova-cli"
             packageName: "cordova"
    +        commit: "master"
             path: "doc/bash.md"
    -    dest: "cordova-cli/index.md"
    +    dest:
    +        permalink: "/docs/en/dev/cordova-cli/index.html"
     -
         src:
    -        repoName: apache/cordova-plugin-battery-status
    -        packageName: cordova-plugin-battery-status
    -        displayName: Battery Status
    -        description: Monitor the status of the device's battery.
    -    dest: cordova-plugin-battery-status/index.md
    +        repoName: "apache/cordova-plugin-battery-status"
    +        packageName: "cordova-plugin-battery-status"
    +    dest:
    +        permalink: "/docs/en/dev/cordova-plugin-battery-status/index.html"
    --- End diff --
    
    Each string here is custom and totally up to change. For example the `/docs/en/dev/` part will have to go once we have translation. I figured the `plugin` part would be redundant since the word is already in the plugin's ID. I can change it to `plugin` though, if you'd prefer. I don't have much of a preference.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53736784
  
    --- Diff: www/_data/toc/de-dev-manual.yml ---
    @@ -1,96 +1,138 @@
     -   name: "Introduction"
         children:
    -        -   name: "Overview"
    -            url: "guide/overview/index.html"
    -#       -   name: "Runtime Architecture"
    -#           url:
    -#       -   name: "Tooling Architecture"
    -#           url:
    +    -   name: "Overview"
    +        url: "guide/overview/index.html"
    +    # -   name: "Runtime Architecture"
    +    #     url:
    +    # -   name: "Tooling Architecture"
    +    #     url:
     -   name: "Create apps"
         children:
    -        -   name: "Create your first app"
    -            url:
    -        -   name: "Platform support"
    -            url: "guide/support/index.html"
    -        -   name: "Develop for platforms"
    -            children:
    -                -   name: "Android"
    -                    url: "guide/platforms/android/index.html"
    -                -   name: "Blackberry 10"
    -                    url: "guide/platforms/blackberry10/home.html"
    -                -   name: "iOS"
    -                    url: "guide/platforms/ios/index.html"
    -                -   name: "Ubuntu"
    -                    url: "guide/platforms/ubuntu/index.html"
    -                -   name: "Windows"
    -                    url: "guide/platforms/win8/index.html"
    -                -   name: "WP8"
    -                    url: "guide/platforms/wp8/home.html"                                                           
    -        -   name: "Manage versions and platforms"
    -            url: "platform_plugin_versioning_ref/index.html"
    -        -   name: "Debug and test"
    -            url:
    -        -   name: "Use icons and splash screens"
    -            url: "config_ref/images.html"
    -        -   name: "Automate Tasks"
    -            url:
    -        -   name: "Store data"
    -            url: "cordova/storage/storage.html"
    -        -   name: "Manage privacy"
    -            url: "guide/appdev/privacy/index.html"
    -        -   name: "Manage security"
    -            url: "guide/appdev/security/index.html"
    -        -   name: "Whitelisting"
    -            url: "guide/appdev/whitelist/index.html"
    -        -   name: "Publish"
    -            url:
    +    # -   name: "Create your first app"
    +    #     url:
    +    -   name: "Platform support"
    +        url: "guide/support/index.html"
    +    -   name: "Develop for platforms"
    +        children:
    +        -   name: "Android"
    +            url: "guide/platforms/android/index.html"
    +        -   name: "Blackberry 10"
    +            url: "guide/platforms/blackberry10/home.html"
    +        -   name: "iOS"
    +            url: "guide/platforms/ios/index.html"
    +        -   name: "Ubuntu"
    +            url: "guide/platforms/ubuntu/index.html"
    +        -   name: "Windows"
    +            url: "guide/platforms/win8/index.html"
    +        -   name: "WP8"
    +            url: "guide/platforms/wp8/home.html"
    +    -   name: "Manage versions and platforms"
    +        url: "platform_plugin_versioning_ref/index.html"
    +    # -   name: "Debug and test"
    +    #     url:
    +    -   name: "Use icons and splash screens"
    +        url: "config_ref/images.html"
    +    # -   name: "Automate Tasks"
    +    #     url:
    +    -   name: "Store data"
    +        url: "cordova/storage/storage.html"
    +    -   name: "Manage privacy"
    +        url: "guide/appdev/privacy/index.html"
    +    -   name: "Manage security"
    +        url: "guide/appdev/security/index.html"
    +    -   name: "Whitelisting"
    +        url: "guide/appdev/whitelist/index.html"
    +    # -   name: "Publish"
    +    #     url:
     -   name: "Create plugins"
         children:
    -        -   name: "Create a plugin"
    -            url: "guide/hybrid/plugins/index.html"
    -        -   name: "Register with NPM"
    -            url:
    -        -   name: "Develop for platforms"
    -            children:
    -                -   name: "Android"
    -                    url: "guide/platforms/android/plugin.html"
    -                -   name: "Blackberry 10"
    -                    url: "guide/platforms/blackberry10/plugin.html"
    -                -   name: "iOS"
    -                    url: "guide/platforms/ios/plugin.html"
    -                -   name: "Windows"
    -                    url: "guide/platforms/win8/plugin.html"
    -                -   name: "WP8"
    -                    url: "guide/platforms/wp8/plugin.html"
    -        -   name: "Use Plugman"
    -            url: "plugin_ref/plugman.html"
    -        -   name: "Debug and test"
    -            url:
    +    -   name: "Create a plugin"
    +        url: "guide/hybrid/plugins/index.html"
    +    # -   name: "Register with NPM"
    +    #     url:
    +    -   name: "Develop for platforms"
    +        children:
    +        -   name: "Android"
    +            url: "guide/platforms/android/plugin.html"
    +        -   name: "Blackberry 10"
    +            url: "guide/platforms/blackberry10/plugin.html"
    +        -   name: "iOS"
    +            url: "guide/platforms/ios/plugin.html"
    +        -   name: "Windows"
    +            url: "guide/platforms/win8/plugin.html"
    +        -   name: "WP8"
    +            url: "guide/platforms/wp8/plugin.html"
    +    -   name: "Use Plugman"
    +        url: "plugin_ref/plugman.html"
    +    # -   name: "Debug and test"
    +    #     url:
     -   name: "Advanced Topics"
         children:
    -        -   name: "Embed Cordova in native apps"
    -            url: "guide/hybrid/webviews/index.html"
    -        -   name: "Pass data from Cordova app to host"
    -            url:
    -        -   name: "Next Steps"
    -            url: "guide/next/index.html"
    +    -   name: "Embed Cordova in native apps"
    +        url: "guide/hybrid/webviews/index.html"
    +    # -   name: "Pass data from Cordova app to host"
    +    #     url:
    +    -   name: "Next Steps"
    +        url: "guide/next/index.html"
     -   name: "Reference"
         children:
    -        -   name: "Config.xml"
    -            url: "config_ref/index.html"
    -        -   name: "Events"
    -            url: "cordova/events/events.html"
    -        -   name: "Plugin APIs"
    -            url: "cordova/plugins/pluginapis.html"
    -        -   name: "CLI"
    -            url: "guide/cli/index.html"
    -        -   name: "Hooks"
    -            url: "guide/appdev/hooks/index.html"
    -        -   name: "Plugin.xml"
    -            url: "plugin_ref/spec.html"
    +    -   name: "Config.xml"
    +        url: "config_ref/index.html"
    +    -   name: "Events"
    +        url: "cordova/events/events.html"
    +    -   name: "Plugin APIs"
    +        children:
    --- End diff --
    
    It will be nice to put the plugin APIs at the end as the last reference topic - it will require less scrolling to get to the other topics.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53841732
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    +        return;
    +    }
    +
    +    if (!srcConfig.repoName) {
    +        console.error("entry '" + entry.toString() + "' missing 'repoName' in 'src'");
    +        return;
    +    }
    +
    +    if (!destConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'dest'");
    +        return;
    +    }
    +
    +    // complete src config
    +    if (!srcConfig.packageName) {
    +        srcConfig.packageName = packageNameFromRepoName(srcConfig.repoName);
    --- End diff --
    
    I prefer very clear `if` statements because with long method/variable names sometimes the `||` is possible to miss. I opted for the former in this case because the names here are quite long.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53814215
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    +        return;
    +    }
    +
    +    if (!srcConfig.repoName) {
    +        console.error("entry '" + entry.toString() + "' missing 'repoName' in 'src'");
    +        return;
    +    }
    +
    +    if (!destConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'dest'");
    +        return;
    +    }
    +
    +    // complete src config
    +    if (!srcConfig.packageName) {
    +        srcConfig.packageName = packageNameFromRepoName(srcConfig.repoName);
    --- End diff --
    
    Nit: The JS way of writing this is: `srcConfig.packageName = srcConfig.packageName || packageNameFromRepoName(srcConfig.repoName);`
    I like it because it's more compact too. This method seems long with a lot of whitespaces making it hard to eyeball - but all of this is just stylistic and not a big deal IMO.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53813684
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    +        return;
    +    }
    +
    +    if (!srcConfig.repoName) {
    +        console.error("entry '" + entry.toString() + "' missing 'repoName' in 'src'");
    +        return;
    +    }
    +
    +    if (!destConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'dest'");
    +        return;
    +    }
    +
    +    // complete src config
    +    if (!srcConfig.packageName) {
    +        srcConfig.packageName = packageNameFromRepoName(srcConfig.repoName);
    +    }
    +
    +    if (!srcConfig.path) {
    +        srcConfig.path = DEFAULT_REPO_PATH;
    +    }
    +
    +    if (!srcConfig.commit) {
    +        srcConfig.commit = getLatestRelease(srcConfig.packageName);
    +    }
    +
    +    // complete dest config
    +    if (!destConfig.permalink) {
    +        destConfig.permalink = DEFAULT_PERMALINK_PREFIX + srcConfig.packageName + "/";
    --- End diff --
    
    We error our when there is no `destconfig` - however, there is a default behavior when the only property of destconfig not present. Either remove this default or remove failing on absence of `destconfig`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53813916
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    --- End diff --
    
    Nit: Consider throwing an error object with appropriate message - throwing often has the nice side effect of presenting a stack. Also, the caller does not have to account for no return value.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53814811
  
    --- Diff: www/_data/fetched-files.yml ---
    @@ -1,153 +1,146 @@
    +# REFERENCE ENTRY:
    +#
    +# -
    +#     src:                                                            # required
    +#         repoName:    "apache/cordova-cli"                           # required
    +#         packageName: "cordova"                                      # if empty: second part of repoName
    +#         commit:      "master"                                       # if empty: latest in NPM
    +#         path:        "relative/path/to/file/in/repo.md"             # if empty: "README.md"
    +#     dest:                                                           # required
    +#         permalink:   "/absolute/path/on/cordova/site/index.html"    # if empty: "/gen/" + packageName + "/"
    +#
    +
     -
         src:
             repoName: "apache/cordova-cli"
             packageName: "cordova"
    +        commit: "master"
             path: "doc/bash.md"
    -    dest: "cordova-cli/index.md"
    +    dest:
    +        permalink: "/docs/en/dev/cordova-cli/index.html"
     -
         src:
    -        repoName: apache/cordova-plugin-battery-status
    -        packageName: cordova-plugin-battery-status
    -        displayName: Battery Status
    -        description: Monitor the status of the device's battery.
    -    dest: cordova-plugin-battery-status/index.md
    +        repoName: "apache/cordova-plugin-battery-status"
    +        packageName: "cordova-plugin-battery-status"
    +    dest:
    +        permalink: "/docs/en/dev/cordova-plugin-battery-status/index.html"
    --- End diff --
    
    Nit: It might be nice to move all plugin docs into one directory "plugins"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53852122
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    --- End diff --
    
    The current behavior is to ignore malformed entries and continue running.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53840883
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    +        return;
    +    }
    +
    +    if (!srcConfig.repoName) {
    +        console.error("entry '" + entry.toString() + "' missing 'repoName' in 'src'");
    +        return;
    +    }
    +
    +    if (!destConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'dest'");
    +        return;
    +    }
    +
    +    // complete src config
    +    if (!srcConfig.packageName) {
    +        srcConfig.packageName = packageNameFromRepoName(srcConfig.repoName);
    +    }
    +
    +    if (!srcConfig.path) {
    +        srcConfig.path = DEFAULT_REPO_PATH;
    +    }
    +
    +    if (!srcConfig.commit) {
    +        srcConfig.commit = getLatestRelease(srcConfig.packageName);
    +    }
    +
    +    // complete dest config
    +    if (!destConfig.permalink) {
    +        destConfig.permalink = DEFAULT_PERMALINK_PREFIX + srcConfig.packageName + "/";
    --- End diff --
    
    Yeah, it does seem paradoxical, but I made `dest` necessary because it could in the future have required arguments. I couldn't decide before, but you're right that it seems wacky. I will just make `permalink` mandatory as well.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by dblotsky <gi...@git.apache.org>.
Github user dblotsky commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53841393
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    --- End diff --
    
    I opted for the "callee prints error and returns null, caller checks for null" instead of the "callee throws exception, caller catches it" pattern. Is one more advantageous than the other?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cordova-docs/pull/514


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] cordova-docs pull request: Docs fetching improvements

Posted by nikhilkh <gi...@git.apache.org>.
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/514#discussion_r53848104
  
    --- Diff: tools/bin/fetch_docs.js ---
    @@ -25,42 +25,103 @@ var child_process = require("child_process");
     var yaml          = require("js-yaml");
     
     // constants
    -var DEFAULT_REPO_PATH = "README.md";
    +var DEFAULT_REPO_PATH        = "README.md";
    +var DEFAULT_PERMALINK_PREFIX = "/gen/";
     
    -function generateFrontMatter (useDirectSrcURI, filePath, name, version) {
    -    var obj                 = {};
    +function generateFrontMatter(fetchedFile) {
     
    -    if(useDirectSrcURI) {
    -        var p               = /https:\/\/raw.githubusercontent.com\/([^\/]+)\/([^\/]+)\/([^\/]+)\/(.+)/;
    -        var filePathSplit   = filePath.match(p);
    -        name                = filePathSplit[1] + "/" + filePathSplit[2];
    -        version             = filePathSplit[3];
    -        filePath            = filePathSplit.slice(4).join("/");
    +    var frontMatterConfig = {};
    +
    +    frontMatterConfig.edit_link = fetchedFile.editLink;
    +    frontMatterConfig.permalink = fetchedFile.permalink;
    +
    +    // set special values for plugins
    +    if (isPluginName(fetchedFile.packageName)) {
    +        frontMatterConfig.plugin_name    = fetchedFile.packageName;
    +        frontMatterConfig.plugin_version = fetchedFile.version;
         }
     
    -    obj.edit_link           = getRepoURIForFrontMatter(name, version, filePath);
    -    obj.plugin_name         = name;
    -    obj.plugin_version      = version;
    +    // return front matter as a string
    +    var frontMatterString = "---\n" + yaml.dump(frontMatterConfig) + "---\n\n";
    +    return frontMatterString;
    +}
     
    -    var frontMatter         = "---\n" + yaml.dump(obj) + "\n---\n\n";
    -    return frontMatter;
    +function isPluginName(packageName) {
    +    return packageName.match(/cordova-plugin-.*/);
     }
     
    -function getRepoFileURI (name, version, filePath) {
    -    return "https://raw.githubusercontent.com/" + name + "/" + version + "/" + filePath;
    +function getRepoFileURI(repoName, commit, filePath) {
    +    return "https://raw.githubusercontent.com/" + repoName + "/" + commit + "/" + filePath;
     }
     
    -function getRepoURIForFrontMatter (name, version, filePath) {
    -    return "https://github.com/" + name + "/blob/" + version + "/"+ filePath
    +function getRepoEditURI(repoName, commit, filePath) {
    +    return "https://github.com/" + repoName + "/blob/" + commit + "/"+ filePath
     }
     
    -function getLatestRelease (packageName) {
    +function getLatestRelease(packageName) {
         var latestRelease = child_process.execSync("npm info " + packageName + " dist-tags.latest");
         return latestRelease.toString().trim();
     }
     
    -function getPackageName (fileConfigSrc) {
    -    return fileConfigSrc.packageName || fileConfigSrc.repoName.split('/')[1];
    +function packageNameFromRepoName(repoName) {
    +    var repoSplit      = repoName.split('/');
    +    var repoOwner      = repoSplit[0];
    +    var actualRepoName = repoSplit[1];
    +    return actualRepoName;
    +}
    +
    +function getFetchedFile(entry) {
    +
    +    // get entry components
    +    var srcConfig  = entry.src;
    +    var destConfig = entry.dest;
    +
    +    // validate entry
    +    if (!srcConfig) {
    +        console.error("entry '" + entry.toString() + "' missing 'src'");
    --- End diff --
    
    In this case you would not catch - it's a truly exceptional case and you can't handle it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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