Skip to content

Commit e7eb4da

Browse files
committed
Updated API box to show other instance names
Now that `Package`, `Npm` and `Cordova` are all instances, we need to show the instance names in more cases (not just `this` in cases like subscriptions and methods). It's not perfect but it's close enough I think.
1 parent 6c01771 commit e7eb4da

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

code

Submodule code updated 516 files

scripts/api-box.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ signature = function (data, options) {
126126
// In general, if we are looking at an instance method, we want to show it as
127127
// Something#foo or #foo (if short). However, when it's on something called
128128
// `this`, we'll do the slightly weird thing of showing `this.foo` in both cases.
129-
if (data.scope === "instance" && apiData(data.memberof).instancename === 'this') {
130-
escapedLongname = "<em>this</em>." + data.name;
131-
} else if (data.scope === "instance" && options.short) {
132-
// Something#foo => #foo
133-
return '<em>' + options.instanceDelimiter + '</em>' + escapedLongname.split('#')[1];
129+
if (data.scope === "instance") {
130+
// the class this method belongs to.
131+
var memberOfData = apiData(data.memberof);
132+
133+
// Certain instances are provided to the user in scope with a specific name
134+
// TBH I'm not sure what else we use instanceName for (why we are setting for
135+
// e.g. `reactiveVar` if we don't want to show it here) but we opt into showing it
136+
if (memberOfData.showinstancename) {
137+
escapedLongname = "<em>" + memberOfData.instancename + "</em>." + data.name;
138+
} else if (options.short) {
139+
// Something#foo => #foo
140+
return '<em>' + options.instanceDelimiter + '</em>' + escapedLongname.split('#')[1];
141+
}
134142
}
135143

136144
// If the user passes in a instanceDelimiter and we are a static method,

source/api/packagejs.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ package) so that Meteor will pick up the local dependency.
8181
Provide basic package information with `Package.describe(options)`. To publish a
8282
package, you must define `summary` and `version`.
8383

84-
{% apibox "Package.describe" %}
84+
{% apibox "PackageNamespace#describe" nested: %}
8585

8686
Define dependencies and expose package methods with the
8787
`Package.onUse` handler. This section lets you define what packages your package
8888
depends on, what packages are implied by your package, and what object your
8989
package is exported to.
9090

91-
{% apibox "Package.onUse" %}
91+
{% apibox "PackageNamespace#onUse" nested: %}
9292

9393
{% apibox "PackageAPI#versionsFrom" %}
9494
{% apibox "PackageAPI#use" %}
@@ -107,15 +107,15 @@ If you used `meteor create` to set up your package, Meteor will create the
107107
required scaffolding in `package.js`, and you'll only need to add unit test code
108108
in the `_test.js` file that was created.
109109

110-
{% apibox "Package.onTest" %}
110+
{% apibox "PackageNamespace#onTest" nested: %}
111111

112112
Meteor packages can include NPM packages and Cordova plugins by using
113113
`Npm.depends` and `Cordova.depends` in the `package.js` file.
114114

115-
{% apibox "Npm.depends" %}
115+
{% apibox "PackageNpm#depends" nested: %}
116116
{% apibox "Npm.require" %}
117-
{% apibox "Cordova.depends" %}
118-
{% apibox "Package.registerBuildPlugin" %}
117+
{% apibox "PackageCordova#depends" nested: %}
118+
{% apibox "PackageNamespace#registerBuildPlugin" nested: %}
119119
{% apibox "Plugin.registerSourceHandler" nested:true %}
120120

121121
<h2 id="build-plugin-api">Build Plugins API</h2>

0 commit comments

Comments
 (0)