mirror of
https://github.com/status-im/metro.git
synced 2025-02-09 09:43:39 +00:00
packager: docBlock: @flow
Reviewed By: cpojer Differential Revision: D5129050 fbshipit-source-id: b77d535b2f5aefef28346709bc1bb9fea5edade9
This commit is contained in:
parent
f0ee61c438
commit
feec96b762
@ -5,6 +5,9 @@
|
|||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the BSD-style license found in the
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -16,7 +19,7 @@ var ltrimRe = /^\s*/;
|
|||||||
* @param {String} contents
|
* @param {String} contents
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function extract(contents) {
|
function extract(contents: string): string {
|
||||||
var match = contents.match(docblockRe);
|
var match = contents.match(docblockRe);
|
||||||
if (match) {
|
if (match) {
|
||||||
return match[0].replace(ltrimRe, '') || '';
|
return match[0].replace(ltrimRe, '') || '';
|
||||||
@ -24,20 +27,18 @@ function extract(contents) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var commentStartRe = /^\/\*\*/;
|
var commentStartRe = /^\/\*\*/;
|
||||||
var commentEndRe = /\*\/$/;
|
var commentEndRe = /\*\/$/;
|
||||||
var wsRe = /[\t ]+/g;
|
var wsRe = /[\t ]+/g;
|
||||||
var stringStartRe = /(\r?\n|^) *\*/g;
|
var stringStartRe = /(\r?\n|^) *\*/g;
|
||||||
var multilineRe =
|
var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
|
||||||
/(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
|
|
||||||
var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
|
var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} contents
|
* @param {String} contents
|
||||||
* @return {Array}
|
* @return {Array}
|
||||||
*/
|
*/
|
||||||
function parse(docblock) {
|
function parse(docblock: string): Array<[string, string]> {
|
||||||
docblock = docblock
|
docblock = docblock
|
||||||
.replace(commentStartRe, '')
|
.replace(commentStartRe, '')
|
||||||
.replace(commentEndRe, '')
|
.replace(commentEndRe, '')
|
||||||
@ -68,7 +69,7 @@ function parse(docblock) {
|
|||||||
* @param {String} contents
|
* @param {String} contents
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
function parseAsObject(docblock) {
|
function parseAsObject(docblock: string): {[string]: string} {
|
||||||
var pairs = parse(docblock);
|
var pairs = parse(docblock);
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var i = 0; i < pairs.length; i++) {
|
for (var i = 0; i < pairs.length; i++) {
|
||||||
@ -77,7 +78,6 @@ function parseAsObject(docblock) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.extract = extract;
|
exports.extract = extract;
|
||||||
exports.parse = parse;
|
exports.parse = parse;
|
||||||
exports.parseAsObject = parseAsObject;
|
exports.parseAsObject = parseAsObject;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user