Permalink
Browse files

working on new documentation system

  • Loading branch information...
1 parent 9ed6194 commit f46f2a0009dd8790bf84c2c3a01534cf9869528f Dominic Barnes committed Sep 11, 2012
Showing with 6,585 additions and 544 deletions.
  1. +1 −16 .jshintrc
  2. +10 −0 Makefile
  3. +58 −0 docs/content.ejs
  4. +180 −0 docs/data/attachment.json
  5. +702 −0 docs/data/database.json
  6. +386 −0 docs/data/designdoc.json
  7. +266 −0 docs/data/document.json
  8. +29 −0 docs/data/localdoc.json
  9. +570 −0 docs/data/server.json
  10. +205 −0 docs/data/view.json
  11. +21 −0 docs/layout.ejs
  12. +35 −0 docs/navigation.ejs
  13. +3,339 −0 docs/output/index.html
  14. +79 −0 docs/render.js
  15. +102 −0 docs/transform.js
  16. +2 −2 index.js
  17. +0 −1 lib/.jshintrc
  18. +13 −0 lib/.jshintrc
  19. +54 −40 lib/attachment.js
  20. +64 −22 lib/client.js
  21. +0 −24 lib/content.js
  22. +144 −160 lib/database.js
  23. +70 −60 lib/designdoc.js
  24. +68 −49 lib/document.js
  25. +22 −10 lib/localdoc.js
  26. +108 −125 lib/server.js
  27. +44 −34 lib/view.js
  28. +0 −1 test/.jshintrc
  29. +13 −0 test/.jshintrc
View
@@ -1,26 +1,11 @@
{
- "predef": [ "_", "provides" ],
-
"browser": false,
"devel": true,
"jquery": false,
"node": true,
"couch": true,
- "bitwise": true,
- "curly": true,
- "eqeqeq": true,
- "forin": true,
- "immed": false,
- "latedef": true,
- "newcap": true,
- "noarg": true,
- "noempty": true,
- "nonow": true,
- "plusplus": false,
- "undef": true,
- "strict": false,
- "trailing": true,
+
"white": true,
"indent": 4,
View
@@ -0,0 +1,10 @@
+clean:
+ rm -f docs/data/*
+ rm -f docs/output/*
+
+docs: clean docs/data/server.json docs/data/database.json docs/data/document.json docs/data/attachment.json docs/data/designdoc.json docs/data/view.json docs/data/localdoc.json
+ node docs/render.js
+
+docs/data/%.json:
+ dox < lib/`basename $@ .json`.js > $@
+ node docs/transform.js $@
View
@@ -0,0 +1,58 @@
+<% libs.forEach(function (api) { %>
+ <% var meta = data[api]; %>
+
+ <article id="<%= api %>">
+ <div class="page-header">
+ <%= meta.intro.description.full %>
+ </div>
+
+ <h3>Methods</h3>
+
+ <% meta.methods.forEach(function (method) { %>
+ <section id="<%= method.ctx.string %>" class="row-fluid">
+ <div class="span8">
+ <h4>
+ <%= api %>.<%= method.ctx.name %>
+ (<%= _.pluck(method.args, "name").join(", ") %>)
+ <%= method.chainable ? "*" : "" %>
+ </h4>
+
+ <% if (method.returns && !method.chainable) { %>
+ <p><b>Returns</b> <%= method.returns.description %></p>
+ <% } %>
+
+ <% if (method.http) { %>
+ <kbd><%= method.http.join(", ") %></kbd>
+ <% } %>
+
+ <%= method.description.full %>
+ </div>
+
+ <div class="span4">
+ <% if (method.args) { %>
+ <div id="<%= api %>-<%= method.ctx.name %>-args">
+ <table class="table table-striped table-bordered table-condensed" align="right">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% method.args.forEach(function (arg) { %>
+ <tr>
+ <td><%= arg.name %></td>
+ <td><code><%= arg.dataTypes.join(", ") %></code></td>
+ <td><%= arg.description %></td>
+ </tr>
+ <% }); %>
+ </tbody>
+ </table>
+ </div>
+ <% } %>
+ </div>
+ </section>
+ <% }); %>
+ </article>
+<% }); %>
View
@@ -0,0 +1,180 @@
+{
+ "api": "attachment",
+ "intro": {
+ "code": "var client = require(\"./client\"),\n prototype = Object.create(client),\n formats = exports.formats = {\n text: \"text/plain\",\n json: \"application/json\",\n html: \"text/html\",\n xml: \"application/xml\"\n };",
+ "description": {
+ "full": "<h2>Attachment API</h2>\n\n<p>An <code>Attachment</code> object represents a single attachment on a document.</p>\n\n<pre><code>var attachment = doc.attachment(\"my-ddoc-name\");\n</code></pre>",
+ "summary": "<h2>Attachment API</h2>",
+ "body": "<p>An <code>Attachment</code> object represents a single attachment on a document.</p>\n\n<pre><code>var attachment = doc.attachment(\"my-ddoc-name\");\n</code></pre>"
+ }
+ },
+ "methods": [
+ {
+ "code": "prototype.setBody = function (format, body) {\n // TODO: Object.defineProperty instead\n this.format = getFormat(format);\n this.body = body;\n return this;\n};",
+ "description": {
+ "full": "<p>Set up the body of this attachment</p>",
+ "summary": "<p>Set up the body of this attachment</p>",
+ "body": ""
+ },
+ "ctx": {
+ "type": "method",
+ "receiver": "attachment",
+ "name": "setBody",
+ "string": "attachment.setBody()"
+ },
+ "http": [],
+ "args": [
+ {
+ "name": "format",
+ "dataTypes": [
+ "String"
+ ],
+ "description": ""
+ },
+ {
+ "name": "body",
+ "dataTypes": [
+ "Various"
+ ],
+ "description": ""
+ }
+ ],
+ "returns": {
+ "dataTypes": [
+ "Attachment"
+ ],
+ "description": "chainable"
+ },
+ "chainable": true
+ },
+ {
+ "code": "prototype.get = function (stream, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = null\n }\n if (typeof stream === \"function\") {\n callback = stream;\n options = null;\n stream = false;\n }\n\n options = options || {};\n options.stream = !!stream;\n if (!(\"json\" in options)) {\n options.json = false;\n }\n\n return this._get(null, options, callback);\n};",
+ "description": {
+ "full": "<p>Retrieve an attachment from a document</p>",
+ "summary": "<p>Retrieve an attachment from a document</p>",
+ "body": ""
+ },
+ "ctx": {
+ "type": "method",
+ "receiver": "attachment",
+ "name": "get",
+ "string": "attachment.get()"
+ },
+ "http": [
+ "GET /db/doc/attachment"
+ ],
+ "args": [
+ {
+ "name": "stream",
+ "dataTypes": [
+ "Boolean"
+ ],
+ "description": ""
+ },
+ {
+ "name": "[options]",
+ "dataTypes": [
+ "Object"
+ ],
+ "description": ""
+ },
+ {
+ "name": "callback",
+ "dataTypes": [
+ "Function"
+ ],
+ "description": ""
+ }
+ ],
+ "returns": {
+ "dataTypes": [
+ "Attachment"
+ ],
+ "description": "chainable"
+ },
+ "chainable": true
+ },
+ {
+ "code": "prototype.save = function (callback) {\n var url = { query: { rev: this.doc.body._rev } },\n opts = { headers: { \"content-type\": this.format } };\n\n if (this.body.pipe) {\n opts.stream = true;\n }\n\n return this._put(url, this.body, opts, function (err, result) {\n if (!err) {\n // update the parent document's rev number\n this.doc.body._rev = result.rev;\n }\n callback.apply(this, arguments);\n });\n};",
+ "description": {
+ "full": "<p>Saves an attachment to the server</p>",
+ "summary": "<p>Saves an attachment to the server</p>",
+ "body": ""
+ },
+ "ctx": {
+ "type": "method",
+ "receiver": "attachment",
+ "name": "save",
+ "string": "attachment.save()"
+ },
+ "http": [
+ "PUT /db/doc/attachment"
+ ],
+ "args": [
+ {
+ "name": "callback",
+ "dataTypes": [
+ "Function"
+ ],
+ "description": ""
+ }
+ ],
+ "returns": {
+ "dataTypes": [
+ "Attachment"
+ ],
+ "description": "chainable"
+ },
+ "chainable": true
+ },
+ {
+ "code": "prototype.del = function (callback) {\n return this._del({\n query: {\n rev: this.doc.body._rev\n }\n }, callback);\n};",
+ "description": {
+ "full": "<p>Removes an attachment from a document on the server</p>",
+ "summary": "<p>Removes an attachment from a document on the server</p>",
+ "body": ""
+ },
+ "ctx": {
+ "type": "method",
+ "receiver": "attachment",
+ "name": "del",
+ "string": "attachment.del()"
+ },
+ "http": [
+ "DELETE /db/doc/attachment"
+ ],
+ "args": [
+ {
+ "name": "callback",
+ "dataTypes": [
+ "Function"
+ ],
+ "description": ""
+ }
+ ],
+ "returns": {
+ "dataTypes": [
+ "Attachment"
+ ],
+ "description": "this"
+ }
+ }
+ ],
+ "properties": [
+ {
+ "code": "Object.defineProperty(prototype, \"name\", {\n get: function () {\n return this._url.path.split(\"/\")[3];\n },\n set: function (v) {\n var path = this._url.path.split(\"/\");\n path[3] = v;\n this._url.path = this._url.pathname = path.join(\"/\");\n }\n});",
+ "tags": [],
+ "description": {
+ "full": "<p>Maintains the name as part of the URL</p>",
+ "summary": "<p>Maintains the name as part of the URL</p>",
+ "body": ""
+ },
+ "ctx": {
+ "type": "property",
+ "receiver": "attachment",
+ "name": "name",
+ "string": "attachment.name"
+ }
+ }
+ ]
+}
Oops, something went wrong.

0 comments on commit f46f2a0

Please sign in to comment.