"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/lib/docs.js" (8 Mar 2017, 2234 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var Docs, View, config, open, yargs,
    3     extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    4     hasProp = {}.hasOwnProperty;
    5 
    6   yargs = require('yargs');
    7 
    8   open = require('open');
    9 
   10   View = require('./view');
   11 
   12   config = require('./apm');
   13 
   14   module.exports = Docs = (function(superClass) {
   15     extend(Docs, superClass);
   16 
   17     function Docs() {
   18       return Docs.__super__.constructor.apply(this, arguments);
   19     }
   20 
   21     Docs.commandNames = ['docs', 'home', 'open'];
   22 
   23     Docs.prototype.parseOptions = function(argv) {
   24       var options;
   25       options = yargs(argv).wrap(100);
   26       options.usage("\nUsage: apm docs [options] <package_name>\n\nOpen a package's homepage in the default browser.");
   27       options.alias('h', 'help').describe('help', 'Print this usage message');
   28       return options.boolean('p').alias('p', 'print').describe('print', 'Print the URL instead of opening it');
   29     };
   30 
   31     Docs.prototype.openRepositoryUrl = function(repositoryUrl) {
   32       return open(repositoryUrl);
   33     };
   34 
   35     Docs.prototype.run = function(options) {
   36       var callback, packageName;
   37       callback = options.callback;
   38       options = this.parseOptions(options.commandArgs);
   39       packageName = options.argv._[0];
   40       if (!packageName) {
   41         callback("Missing required package name");
   42         return;
   43       }
   44       return this.getPackage(packageName, options, (function(_this) {
   45         return function(error, pack) {
   46           var repository;
   47           if (error != null) {
   48             return callback(error);
   49           }
   50           if (repository = _this.getRepository(pack)) {
   51             if (options.argv.print) {
   52               console.log(repository);
   53             } else {
   54               _this.openRepositoryUrl(repository);
   55             }
   56             return callback();
   57           } else {
   58             return callback("Package \"" + packageName + "\" does not contain a repository URL");
   59           }
   60         };
   61       })(this));
   62     };
   63 
   64     return Docs;
   65 
   66   })(View);
   67 
   68 }).call(this);