(path)
| 849 | } |
| 850 | |
| 851 | function getJSDocs(path) { |
| 852 | let comments = getDocComments(path); |
| 853 | if (comments) { |
| 854 | let parsed = doctrine.parse(comments, { |
| 855 | // have doctrine itself remove the comment asterisks from content |
| 856 | unwrap: true, |
| 857 | // enable parsing of optional parameters in brackets, JSDoc3 style |
| 858 | sloppy: true, |
| 859 | // `recoverable: true` is the only way to get error information out |
| 860 | recoverable: true |
| 861 | }); |
| 862 | |
| 863 | let result = { |
| 864 | description: parsed.description |
| 865 | }; |
| 866 | |
| 867 | for (let tag of parsed.tags) { |
| 868 | if (tag.title === 'default') { |
| 869 | result.default = tag.description; |
| 870 | } else if (tag.title === 'access') { |
| 871 | result.access = tag.description; |
| 872 | } else if (tag.title === 'private' || tag.title === 'deprecated') { |
| 873 | result.access = 'private'; |
| 874 | } else if (tag.title === 'protected') { |
| 875 | result.access = 'protected'; |
| 876 | } else if (tag.title === 'public') { |
| 877 | result.access = 'public'; |
| 878 | } else if (tag.title === 'return' || tag.title === 'returns') { |
| 879 | result.return = tag.description; |
| 880 | } else if (tag.title === 'param') { |
| 881 | if (!result.params) { |
| 882 | result.params = {}; |
| 883 | } |
| 884 | |
| 885 | result.params[tag.name] = tag.description; |
| 886 | } else if (tag.title === 'selector') { |
| 887 | result.selector = tag.description; |
| 888 | } else if (tag.title === 'example') { |
| 889 | if (!result.examples) { |
| 890 | result.examples = []; |
| 891 | } |
| 892 | |
| 893 | if (tag.description) { |
| 894 | result.examples.push( |
| 895 | tag.description |
| 896 | .split('\n') |
| 897 | .map(line => line.replace(/^\s{2}/, '')) |
| 898 | .join('\n') |
| 899 | ); |
| 900 | } |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | if (result.examples) { |
| 905 | result.examples = [ |
| 906 | ...new Set(result.examples.map(example => example.trim()).filter(Boolean)) |
| 907 | ]; |
| 908 | } |
no test coverage detected