Closed jleyba closed 7 years ago
For each page, the type header currently links to the parent type. So we get something like:
<div><b>Namespace: </b><code><a>goog</a></code></div> <h1>goog.Promise</h1>
The problem is while goog.Promise is a direct descendant of goog, it still needs to be explicitly required.
goog.Promise
goog
Option 1: Render the declarative statement.
<div><code>goog.provide(<a>'goog.Promise'</a>)</code></div> <h1>Class goog.Promise</h1>
This doesn't work as well for types exported by a module:
<div><code>goog.module(<a>'foo.bar'</a>)</code></div> <h1>Class SomeClass</h1>
Option 2: Render the import statement.
This works well for modules:
<div><code>const {SomeClass} = goog.require(<a>'foo.bar'</a>)</code></div> <h1>Class SomeClass</h1>
It does not work as well for types that use goog.provide since the import statement depends on the context:
goog.provide
<div><code>goog.require(<a>'goog.Promise'</a>)</code></div> <h1>Class goog.Promise</h1>
<div><code>const Promise = goog.require(<a>'goog.Promise'</a>)</code></div> <h1>Class goog.Promise</h1>
I'm inclined to go with Option 1 and render the declaration for the closest parent (whether it's a goog.provide or goog.module style). In the case of CommonJS/ES6 modules, the module path would be rendered.
goog.module
For each page, the type header currently links to the parent type. So we get something like:
The problem is while
goog.Promise
is a direct descendant ofgoog
, it still needs to be explicitly required.Option 1: Render the declarative statement.
This doesn't work as well for types exported by a module:
Option 2: Render the import statement.
This works well for modules:
It does not work as well for types that use
goog.provide
since the import statement depends on the context:I'm inclined to go with Option 1 and render the declaration for the closest parent (whether it's a
goog.provide
orgoog.module
style). In the case of CommonJS/ES6 modules, the module path would be rendered.