fix(docs-infra): rename "title" by "header" to avoid unwanted tooltips (#26396)
Closes #26174 PR Close #26396
This commit is contained in:

committed by
Misko Hevery

parent
017a087f9b
commit
b29e709208
@ -3,19 +3,19 @@ var entities = require('entities');
|
||||
/**
|
||||
* @dgService exampleInlineTagDef
|
||||
* @description
|
||||
* Process inline example tags (of the form {@example relativePath region -title='some title'
|
||||
* Process inline example tags (of the form {@example relativePath region -header='some header'
|
||||
* -stylePattern='{some style pattern}' }),
|
||||
* replacing them with code from a shredded file
|
||||
* Examples:
|
||||
* {@example core/application_spec.ts hello-app -title='Sample component' }
|
||||
* {@example core/application_spec.ts -region=hello-app -title='Sample component' }
|
||||
* {@example core/application_spec.ts hello-app -header='Sample component' }
|
||||
* {@example core/application_spec.ts -region=hello-app -header='Sample component' }
|
||||
* @kind function
|
||||
*/
|
||||
module.exports = function exampleInlineTagDef(parseArgString, createDocMessage, getExampleRegion) {
|
||||
return {
|
||||
name: 'example',
|
||||
description:
|
||||
'Process inline example tags (of the form {@example some/uri Some Title}), replacing them with HTML anchors',
|
||||
'Process inline example tags (of the form {@example some/uri some-region Some header}), replacing them with HTML anchors',
|
||||
|
||||
|
||||
handler: function(doc, tagName, tagDescription) {
|
||||
@ -24,14 +24,14 @@ module.exports = function exampleInlineTagDef(parseArgString, createDocMessage,
|
||||
var relativePath = unnamedArgs[0];
|
||||
var regionName = tagArgs.region || (unnamedArgs.length > 1 ? unnamedArgs[1] : '');
|
||||
if (regionName === '\'\'') regionName = '';
|
||||
var title = tagArgs.title || (unnamedArgs.length > 2 ? unnamedArgs.slice(2).join(' ') : null);
|
||||
var header = tagArgs.header || (unnamedArgs.length > 2 ? unnamedArgs.slice(2).join(' ') : null);
|
||||
var linenums = tagArgs.linenums;
|
||||
// var stylePattern = tagArgs.stylePattern; // TODO: not yet implemented here
|
||||
|
||||
const sourceCode = getExampleRegion(doc, relativePath, regionName);
|
||||
|
||||
const attributes = [];
|
||||
if (title) attributes.push(` title="${title}"`);
|
||||
if (header) attributes.push(` header="${header}"`);
|
||||
if (linenums !== undefined) attributes.push(` linenums="${linenums}"`);
|
||||
|
||||
return '<code-example' + attributes.join('') + '>\n' + sourceCode + '\n</code-example>';
|
||||
|
@ -49,14 +49,14 @@ describe('example inline-tag-def', function() {
|
||||
expect(handler({}, 'example', 'test/url region-1')).toEqual('<code-example>\nregion 1 contents\n</code-example>');
|
||||
});
|
||||
|
||||
it('should add a title if specified', () => {
|
||||
expect(handler({}, 'example', 'test/url region-1 \'Some Title\'')).toEqual('<code-example title="Some Title">\nregion 1 contents\n</code-example>');
|
||||
expect(handler({}, 'example', 'test/url region-1 Some Title')).toEqual('<code-example title="Some Title">\nregion 1 contents\n</code-example>');
|
||||
it('should add a header if specified', () => {
|
||||
expect(handler({}, 'example', 'test/url region-1 \'Some Header\'')).toEqual('<code-example header="Some Header">\nregion 1 contents\n</code-example>');
|
||||
expect(handler({}, 'example', 'test/url region-1 Some Header')).toEqual('<code-example header="Some Header">\nregion 1 contents\n</code-example>');
|
||||
});
|
||||
|
||||
it('should contain the whole contents from the example file if an empty ("") region is specified', () => {
|
||||
expect(handler({}, 'example', 'test/url \'\'')).toEqual('<code-example>\nwhole file\n</code-example>');
|
||||
expect(handler({}, 'example', 'test/url \'\' Some Title')).toEqual('<code-example title="Some Title">\nwhole file\n</code-example>');
|
||||
expect(handler({}, 'example', 'test/url \'\' Some Header')).toEqual('<code-example header="Some Header">\nwhole file\n</code-example>');
|
||||
});
|
||||
|
||||
it('should add in linenum attribute if specified', () => {
|
||||
|
Reference in New Issue
Block a user