Merge pull request #10588 from ahocevar/apidoc

Sort doc navigation properly and add missing modules
This commit is contained in:
Andreas Hocevar
2020-01-30 08:15:41 +01:00
committed by GitHub
9 changed files with 29 additions and 19 deletions

View File

@@ -188,6 +188,12 @@ function attachModuleSymbols(doclets, modules) {
}); });
} }
function getPrettyName(longname) {
return longname
.split('~')[0]
.replace('module:', '');
}
/** /**
* Create the navigation sidebar. * Create the navigation sidebar.
* @param {object} members The members that will be used to create the sidebar. * @param {object} members The members that will be used to create the sidebar.
@@ -206,10 +212,12 @@ function buildNav(members) {
// merge namespaces and classes, then sort // merge namespaces and classes, then sort
const merged = members.modules.concat(members.classes); const merged = members.modules.concat(members.classes);
merged.sort(function(a, b) { merged.sort(function(a, b) {
if (a.longname > b.longname) { const prettyNameA = getPrettyName(a.longname).toLowerCase();
const prettyNameB = getPrettyName(b.longname).toLowerCase();
if (prettyNameA > prettyNameB) {
return 1; return 1;
} }
if (a.longname < b.longname) { if (prettyNameA < prettyNameB) {
return -1; return -1;
} }
return 0; return 0;
@@ -221,9 +229,7 @@ function buildNav(members) {
nav.push({ nav.push({
type: 'class', type: 'class',
longname: v.longname, longname: v.longname,
prettyname: v.longname prettyname: getPrettyName(v.longname),
.split('~')[0]
.replace('module:', ''),
name: v.name, name: v.name,
module: find({ module: find({
kind: 'module', kind: 'module',
@@ -268,14 +274,13 @@ function buildNav(members) {
kind: 'event', kind: 'event',
memberof: v.longname memberof: v.longname
}); });
// only add modules that have more to show than just a single class // only add modules that have more to show than just classes
if (classes.length !== 1 && (classes.length + members.length + methods.length + typedefs.length + events.length > 0)) { const numItems = classes.length - 1 + members.length + methods.length + typedefs.length + events.length;
if (!classes.length || (numItems > 0 && numItems !== classes.length)) {
nav.push({ nav.push({
type: 'module', type: 'module',
longname: v.longname, longname: v.longname,
prettyname: v.longname prettyname: getPrettyName(v.longname),
.split('~')[0]
.replace('module:', ''),
name: v.name, name: v.name,
members: members, members: members,
methods: methods, methods: methods,

View File

@@ -325,7 +325,6 @@ class Attribution extends Control {
* Update the attribution element. * Update the attribution element.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {Attribution} * @this {Attribution}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
this.updateElement_(mapEvent.frameState); this.updateElement_(mapEvent.frameState);

View File

@@ -79,9 +79,10 @@ class Control extends BaseObject {
this.listenerKeys = []; this.listenerKeys = [];
/** /**
* @private
* @type {function(import("../MapEvent.js").default): void} * @type {function(import("../MapEvent.js").default): void}
*/ */
this.render = options.render ? options.render : VOID; this.render_ = options.render ? options.render : VOID;
if (options.target) { if (options.target) {
this.setTarget(options.target); this.setTarget(options.target);
@@ -134,6 +135,16 @@ class Control extends BaseObject {
} }
} }
/**
* Update the projection. Rendering of the coordinates is done in
* `handleMouseMove` and `handleMouseUp`.
* @param {import("../MapEvent.js").default} mapEvent Map event.
* @api
*/
render(mapEvent) {
this.render_.call(this, mapEvent);
}
/** /**
* This function is used to set a target element for the control. It has no * This function is used to set a target element for the control. It has no
* effect if it is called after the control has been added to the map (i.e. * effect if it is called after the control has been added to the map (i.e.

View File

@@ -248,7 +248,6 @@ class MousePosition extends Control {
* `handleMouseMove` and `handleMouseUp`. * `handleMouseMove` and `handleMouseUp`.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {MousePosition} * @this {MousePosition}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;

View File

@@ -603,7 +603,6 @@ class OverviewMap extends Control {
* Update the overview map element. * Update the overview map element.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {OverviewMap} * @this {OverviewMap}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
this.validateExtent_(); this.validateExtent_();

View File

@@ -151,7 +151,6 @@ class Rotate extends Control {
* Update the rotate control element. * Update the rotate control element.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {Rotate} * @this {Rotate}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;

View File

@@ -418,7 +418,6 @@ class ScaleLine extends Control {
* Update the scale line element. * Update the scale line element.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {ScaleLine} * @this {ScaleLine}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
const frameState = mapEvent.frameState; const frameState = mapEvent.frameState;

View File

@@ -339,7 +339,6 @@ class ZoomSlider extends Control {
* Update the zoomslider element. * Update the zoomslider element.
* @param {import("../MapEvent.js").default} mapEvent Map event. * @param {import("../MapEvent.js").default} mapEvent Map event.
* @this {ZoomSlider} * @this {ZoomSlider}
* @api
*/ */
export function render(mapEvent) { export function render(mapEvent) {
if (!mapEvent.frameState) { if (!mapEvent.frameState) {

View File

@@ -70,14 +70,14 @@ describe('ol.control.ScaleLine', function() {
describe('render', function() { describe('render', function() {
it('defaults to `ol.control.ScaleLine.render`', function() { it('defaults to `ol.control.ScaleLine.render`', function() {
const ctrl = new ScaleLine(); const ctrl = new ScaleLine();
expect(ctrl.render).to.be(render); expect(ctrl.render_).to.be(render);
}); });
it('can be configured', function() { it('can be configured', function() {
const myRender = function() {}; const myRender = function() {};
const ctrl = new ScaleLine({ const ctrl = new ScaleLine({
render: myRender render: myRender
}); });
expect(ctrl.render).to.be(myRender); expect(ctrl.render_).to.be(myRender);
}); });
}); });