build(docs-infra): allow `""` as empty region in `{@example}` tags (#26514)

PR Close #26514
This commit is contained in:
George Kalpakas 2018-10-18 14:33:46 +03:00 committed by Miško Hevery
parent 7bad1d356d
commit d9d226087c
2 changed files with 8 additions and 2 deletions

View File

@ -23,7 +23,7 @@ module.exports = function exampleInlineTagDef(parseArgString, createDocMessage)
var unnamedArgs = tagArgs._;
var relativePath = unnamedArgs[0];
var regionName = tagArgs.region || (unnamedArgs.length > 1 ? unnamedArgs[1] : '');
if (regionName === '\'\'') regionName = '';
if (regionName === '\'\'' || regionName === '""') regionName = '';
var header = tagArgs.header || (unnamedArgs.length > 2 ? unnamedArgs.slice(2).join(' ') : '');
var linenums = tagArgs.linenums;
// var stylePattern = tagArgs.stylePattern; // TODO: not yet implemented here

View File

@ -42,12 +42,18 @@ describe('example inline-tag-def', function() {
'<code-example path="test/url" region="region-1"></code-example>');
});
it('should add no region if an empty (\'\') region is specified', () => {
it('should add no region if an empty (\'\'/"") region is specified', () => {
expect(handler({}, 'example', 'test/url \'\'')).toEqual(
'<code-example path="test/url"></code-example>');
expect(handler({}, 'example', 'test/url ""')).toEqual(
'<code-example path="test/url"></code-example>');
expect(handler({}, 'example', 'test/url \'\' Some Header')).toEqual(
'<code-example path="test/url" header="Some Header"></code-example>');
expect(handler({}, 'example', 'test/url "" Some Header')).toEqual(
'<code-example path="test/url" header="Some Header"></code-example>');
});
it('should add a header if specified', () => {