Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

Commit f22b185

Browse files
committed
Hooked up submodule -> meteor/meteor and documented
1 parent 3da36cc commit f22b185

File tree

12 files changed

+251
-34
lines changed

12 files changed

+251
-34
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "themes/meteor"]
22
path = themes/meteor
33
url = https://github.com/meteor/hexo-theme-meteor.git
4+
[submodule "code"]
5+
path = code
6+
url = https://github.com/meteor/meteor.git

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Meteor Documentation - http://docs.meteor.com
2+
3+
This is a [hexo](https://hexo.io) static site used to generate the [Meteor Docs](http://docs.meteor.com).
4+
5+
## Contributing
6+
7+
We'd love your contributions! Please send us Pull Requests or open issues on [github](https://github.com/meteor/docs).
8+
9+
If you are making a larger contribution, you may need to run the site locally. There are a few things you need to know:
10+
11+
### Submodules
12+
13+
This repo has two submodules, one the theme, the other full Meteor repository.
14+
15+
We have the Meteor repo to generate the `data.js` file (see below).
16+
17+
After cloning, or updating the repo, it makes sense to run
18+
19+
```
20+
git submodule update --init
21+
```
22+
23+
Generally you should not commit changes to the submodules, unless you know what you are doing.
24+
25+
### Generating `data.js`
26+
27+
To generate the api boxes, the site uses a file `data/data.js` which is generated from the js docs in the [Meteor source code](https://github.com/meteor/meteor). This will automatically happen whenever you start your local hexo server.
28+
29+
### Starting hexo
30+
31+
Ensure you've run `npm install`. Then simply `npm start`.

_config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ sidebar_categories:
5656
- packages/webapp
5757
Command Line:
5858
- commandline
59-
github_repo: 'meteor/meteor'
60-
content_root: 'docs/source'
59+
github_repo: 'meteor/docs'
60+
content_root: 'source'
6161

6262
# URL
6363
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
@@ -114,7 +114,7 @@ pagination_dir: page
114114
## Themes: http://hexo.io/themes/
115115
theme: meteor
116116
api_box:
117-
data_file: 'data.js'
117+
data_file: 'data/data.js'
118118
marked:
119119
breaks: false
120120

code

Submodule code added at 8503736

data.js data/data.js

+4-26
Original file line numberDiff line numberDiff line change
@@ -1639,27 +1639,6 @@ module.exports = {
16391639
"scope": "global",
16401640
"summary": "The namespace for Assets functions, lives in the bundler."
16411641
},
1642-
"Assets.absoluteFilePath": {
1643-
"kind": "function",
1644-
"locus": "Server [not build plugins]",
1645-
"longname": "Assets.absoluteFilePath",
1646-
"memberof": "Assets",
1647-
"name": "absoluteFilePath",
1648-
"options": [],
1649-
"params": [
1650-
{
1651-
"description": "<p>The path of the asset, relative to the application's <code>private</code> subdirectory.</p>",
1652-
"name": "assetPath",
1653-
"type": {
1654-
"names": [
1655-
"String"
1656-
]
1657-
}
1658-
}
1659-
],
1660-
"scope": "static",
1661-
"summary": "Retrieve the full file path of a file on disk"
1662-
},
16631642
"Assets.getBinary": {
16641643
"kind": "function",
16651644
"locus": "Server",
@@ -4632,7 +4611,7 @@ module.exports = {
46324611
"Match": {
46334612
"filepath": "check/match.js",
46344613
"kind": "namespace",
4635-
"lineno": 42,
4614+
"lineno": 43,
46364615
"longname": "Match",
46374616
"module": "check",
46384617
"name": "Match",
@@ -4642,7 +4621,7 @@ module.exports = {
46424621
"Match.test": {
46434622
"filepath": "check/match.js",
46444623
"kind": "function",
4645-
"lineno": 95,
4624+
"lineno": 96,
46464625
"locus": "Anywhere",
46474626
"longname": "Match.test",
46484627
"memberof": "Match",
@@ -8358,13 +8337,12 @@ module.exports = {
83588337
},
83598338
"check": {
83608339
"filepath": "check/match.js",
8361-
"kind": "function",
8362-
"lineno": 19,
8340+
"kind": "member",
8341+
"lineno": 20,
83638342
"locus": "Anywhere",
83648343
"longname": "check",
83658344
"module": "check",
83668345
"name": "check",
8367-
"options": [],
83688346
"params": [
83698347
{
83708348
"description": "<p>The value to check</p>",

names.json data/names.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"App.launchScreens",
5454
"App.setPreference",
5555
"Assets",
56-
"Assets.absoluteFilePath",
5756
"Assets.getBinary",
5857
"Assets.getText",
5958
"Blaze",
+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/*global require: true */
2+
(function () {
3+
'use strict';
4+
5+
// This file receives data from JSDoc via the `publish` exported function,
6+
// and converts it into JSON that is written to a file.
7+
8+
var fs = require('jsdoc/fs');
9+
var helper = require('jsdoc/util/templateHelper');
10+
11+
var _ = require("underscore");
12+
var stringify = require("canonical-json");
13+
14+
// This is the big map of name -> data that we'll write to a file.
15+
var dataContents = {};
16+
// List of just the names, which we'll also write to a file.
17+
var names = [];
18+
19+
/**
20+
* Get a tag dictionary from the tags field on the object, for custom fields
21+
* like package
22+
* @param {JSDocData} data The thing you get in the TaffyDB from JSDoc
23+
* @return {Object} Keys are the parameter names, values are the values.
24+
*/
25+
var getTagDict = function (data) {
26+
var tagDict = {};
27+
28+
if (data.tags) {
29+
_.each(data.tags, function (tag) {
30+
tagDict[tag.title] = tag.value;
31+
});
32+
}
33+
34+
return tagDict;
35+
};
36+
37+
// Fix up a JSDoc entry and add it to `dataContents`.
38+
var addToData = function (entry) {
39+
_.extend(entry, getTagDict(entry));
40+
41+
// strip properties we don't want
42+
entry.comment = undefined;
43+
entry.___id = undefined;
44+
entry.___s = undefined;
45+
entry.tags = undefined;
46+
47+
// generate `.filepath` and `.lineno` from `.meta`
48+
if (entry.meta && entry.meta.path) {
49+
var packagesFolder = 'packages/';
50+
var index = entry.meta.path.indexOf(packagesFolder);
51+
if (index != -1) {
52+
var fullFilePath = entry.meta.path.substr(index + packagesFolder.length) + '/' + entry.meta.filename;
53+
entry.filepath = fullFilePath;
54+
entry.lineno = entry.meta.lineno;
55+
}
56+
}
57+
58+
entry.meta = undefined;
59+
60+
if (!entry.importfrompackage && entry.filepath) {
61+
entry.module = entry.filepath.split('/')[0];
62+
} else {
63+
entry.module = entry.importfrompackage;
64+
}
65+
66+
names.push(entry.longname);
67+
dataContents[entry.longname] = entry;
68+
};
69+
70+
/**
71+
Entry point where JSDoc calls us. It passes us data in the form of
72+
a TaffyDB object (which is an in-JS database of sorts that you can
73+
query for records.
74+
75+
@param {TAFFY} taffyData See <http://taffydb.com/>.
76+
@param {object} opts
77+
@param {Tutorial} tutorials
78+
*/
79+
exports.publish = function(taffyData) {
80+
var data = helper.prune(taffyData);
81+
82+
var namespaces = helper.find(data, {kind: "namespace"});
83+
84+
// prepare all of the namespaces
85+
_.each(namespaces, function (namespace) {
86+
if (namespace.summary) {
87+
addToData(namespace);
88+
}
89+
});
90+
91+
var properties = helper.find(data, {kind: "member"});
92+
93+
_.each(properties, function (property) {
94+
if (property.summary) {
95+
addToData(property);
96+
}
97+
});
98+
99+
// Callback descriptions are going to be embeded into Function descriptions
100+
// when they are used as arguments, so we always attach them to reference
101+
// them later.
102+
var callbacks = helper.find(data, {kind: "typedef"});
103+
_.each(callbacks, function (cb) {
104+
delete cb.comment;
105+
addToData(cb);
106+
});
107+
108+
var functions = helper.find(data, {kind: "function"});
109+
var constructors = helper.find(data, {kind: "class"});
110+
111+
// we want to do all of the same transformations to classes and functions
112+
functions = functions.concat(constructors);
113+
114+
// insert all of the function data into the namespaces
115+
_.each(functions, function (func) {
116+
if (! func.summary) {
117+
// we use the @summary tag to indicate that an item is documented
118+
return;
119+
}
120+
121+
func.options = [];
122+
var filteredParams = [];
123+
124+
// Starting a param with `options.` makes it an option, not a
125+
// param. Dot (`.`) in this case binds tighter than comma, so
126+
// `options.foo,bar` will create an option named `foo, bar`
127+
// (representing two options in the docs). We process pipes so
128+
// that `options.foo|bar` also results in `foo, bar`.
129+
_.each(func.params, function (param) {
130+
param.name = param.name.replace(/,|\|/g, ", ");
131+
132+
var splitName = param.name.split(".");
133+
134+
if (splitName.length < 2 || splitName[0] !== "options") {
135+
// not an option
136+
filteredParams.push(param);
137+
return;
138+
}
139+
140+
param.name = splitName[1];
141+
142+
func.options.push(param);
143+
});
144+
145+
func.params = filteredParams;
146+
147+
// the entire unparsed doc comment. takes up too much room in the
148+
// data file.
149+
delete func.comment;
150+
151+
addToData(func);
152+
});
153+
154+
// write full docs JSON
155+
var jsonString = stringify(dataContents, null, 2);
156+
var jsString = "module.exports = " + jsonString + ";";
157+
jsString = "// This file is automatically generated by JSDoc; regenerate it with scripts/admin/jsdoc/jsdoc.sh\n" + jsString;
158+
var docsDataFilename = "../data/data.js";
159+
fs.writeFileSync(docsDataFilename, jsString);
160+
161+
// write name tree JSON
162+
jsonString = stringify(names.sort(), null, 2);
163+
var nameTreeFilename= "../data/names.json";
164+
fs.writeFileSync(nameTreeFilename, jsonString);
165+
};
166+
})();

jsdoc/jsdoc-conf.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"plugins": ["plugins/markdown"],
3+
"markdown": {
4+
"parser": "gfm"
5+
},
6+
"source": {
7+
"exclude": [
8+
"packages/ddp/sockjs-0.3.4.js",
9+
"packages/test-in-browser/diff_match_patch_uncompressed.js",
10+
"packages/jquery/jquery.js",
11+
"packages/underscore/underscore.js",
12+
"packages/json/json2.js",
13+
"packages/minimongo/minimongo_tests.js",
14+
"tools/node_modules",
15+
"tools/skel-pack/package.js"
16+
]
17+
}
18+
}

jsdoc/jsdoc.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
INFINITY=10000
4+
5+
TOPDIR=$(pwd)
6+
METEOR_DIR="./code"
7+
cd "$METEOR_DIR"
8+
9+
# Call git grep to find all js files with the appropriate comment tags,
10+
# and only then pass it to JSDoc which will parse the JS files.
11+
# This is a whole lot faster than calling JSDoc recursively.
12+
git grep -al "@summary" | xargs -L ${INFINITY} -t \
13+
"$TOPDIR/node_modules/.bin/jsdoc" \
14+
-t "$TOPDIR/jsdoc/docdata-jsdoc-template" \
15+
-c "$TOPDIR/jsdoc/jsdoc-conf.json" \
16+
2>&1 | grep -v 'WARNING: JSDoc does not currently handle'

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@
1717
"hexo-renderer-stylus": "^0.3.0",
1818
"hexo-server": "^0.1.2",
1919
"showdown": "^1.3.0",
20-
"underscore": "^1.8.3"
20+
"underscore": "^1.8.3",
21+
"jsdoc": "git+https://github.com/jsdoc3/jsdoc.git",
22+
"canonical-json": "0.0.4"
2123
},
2224
"devDependencies": {
2325
"hexo-s3-deploy": "^1.0.1"
2426
},
2527
"scripts": {
26-
"deploy": "hexo-s3-deploy"
28+
"predeploy": "jsdoc/jsdoc.sh",
29+
"deploy": "hexo-s3-deploy",
30+
"prestart": "jsdoc/jsdoc.sh",
31+
"start": "hexo server"
2732
}
2833
}

scripts/api-box.js

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var path = require('path');
44
var fs = require('fs');
55
var handlebars = require('handlebars');
66
var _ = require('underscore');
7-
var nameToId = require(path.join(__dirname, 'nameToId.js'));
87
var parseTagOptions = require('./parseTagOptions');
98
var showdown = require('showdown');
109
var converter = new showdown.Converter();

source/api/assets.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ into your application's bundle.
1010

1111
{% apibox "Assets.getText" %}
1212
{% apibox "Assets.getBinary" %}
13-
{% apibox "Assets.absoluteFilePath" %}
13+
<!-- commented out because this does not exist in master -->
14+
<!-- { % apibox "Assets.absoluteFilePath" %} -->
1415

1516
Static server assets are included by placing them in the application's `private`
1617
subdirectory. For example, if an application's `private` subdirectory includes a

0 commit comments

Comments
 (0)