Browse Source

Improved API docs generation

Artur Paikin 9 years ago
parent
commit
292c8d6326
4 changed files with 71 additions and 12 deletions
  1. 8 3
      src/plugins/DragDrop.js
  2. 19 7
      website/documentation.js
  3. 2 0
      website/package.json
  4. 42 2
      website/src/api/docs.md

+ 8 - 3
src/plugins/DragDrop.js

@@ -1,6 +1,10 @@
 import Utils from '../core/Utils';
 import Plugin from './Plugin';
 
+/**
+* Drag & Drop plugin
+*
+*/
 export default class DragDrop extends Plugin {
   constructor(core, opts) {
     super(core, opts);
@@ -32,9 +36,10 @@ export default class DragDrop extends Plugin {
     this.handleInputChange    = this.handleInputChange.bind(this);
   }
 
-  /**
-   * Checks if the browser supports Drag & Drop
-   */
+   /**
+  * Checks if the browser supports Drag & Drop
+  * @returns {object} true if Drag & Drop is supported, false otherwise
+  */
   checkDragDropSupport() {
     const div = document.createElement('div');
 

+ 19 - 7
website/documentation.js

@@ -4,11 +4,23 @@ var fs = require('fs');
 
 var docsFrontmatter = '---\ntype: api\norder: 1\ntitle: "Generated API Docs"\n---\n';
 
-documentation('../src/core/Core.js', {}, function (err, comments) {
-  documentationFormatter(comments, {}, function (err, output) {
-    var docsWithFrontmatter = docsFrontmatter + output;
-    // console.log(docsWithFrontmatter);
-    fs.writeFileSync('src/api/docs.md', docsWithFrontmatter);
-    console.log('documentation generated');
-  });
+// documentation('../src/index.js', {}, function (err, comments) {
+//   documentationFormatter(comments, {}, function (err, output) {
+//     var docsWithFrontmatter = docsFrontmatter + output;
+//     // console.log(docsWithFrontmatter);
+//     fs.writeFileSync('src/api/docs.md', docsWithFrontmatter);
+//     console.log('documentation generated');
+//   });
+// });
+
+var remark = require('remark');
+var inputMarkdownContent = fs.readFileSync('src/api/docs.md', 'utf-8');
+var docjsReadme = require('documentation-readme/lib/plugin');
+remark().use(docjsReadme, {
+ section: 'Uppy Core & Plugins', // inject into the ## Usage section of the input doc
+ documentationArgs: [ '../src/index.js' ]
+}).process(inputMarkdownContent, function (err, vfile, content) {
+fs.writeFileSync('src/api/docs.md', content);
+ // console.log(content);
+ console.log('documentation generated');
 });

+ 2 - 0
website/package.json

@@ -30,9 +30,11 @@
     "browserify": "^12.0.1",
     "chalk": "^1.1.1",
     "documentation": "^3.0.4",
+    "documentation-readme": "^2.1.1",
     "glob": "^6.0.1",
     "multi-glob": "^1.0.1",
     "node-notifier": "^4.4.0",
+    "remark": "^3.0.0",
     "watchify": "^3.6.1"
   }
 }

+ 42 - 2
website/src/api/docs.md

@@ -3,7 +3,47 @@ type: api
 order: 1
 title: "Generated API Docs"
 ---
-# setProgress
+
+# Uppy Core & Plugins
+
+## DragDrop
+
+Drag & Drop plugin
+
+**Parameters**
+
+-   `core`  
+-   `opts`  
+
+### checkDragDropSupport
+
+Checks if the browser supports Drag & Drop
+
+Returns **object** true if Drag & Drop is supported, false otherwise
+
+## Core
+
+Main Uppy core
+
+**Parameters**
+
+-   `opts`  
+
+### run
+
+Runs a waterfall of runType plugin packs, like so:
+All preseters(data) --> All selecters(data) --> All uploaders(data) --> done
+
+### runType
+
+Runs all plugins of the same type in parallel
+
+**Parameters**
+
+-   `type`  
+-   `files`  
+
+### setProgress
 
 Sets plugin’s progress, for uploads for example
 
@@ -15,7 +55,7 @@ Sets plugin’s progress, for uploads for example
 
 Returns **object** self for chaining
 
-# use
+### use
 
 Registers a plugin with Core