Reference Source Test

src/Doc/ExternalDoc.js

  1. import log from 'npmlog';
  2. import AbstractDoc from './AbstractDoc.js';
  3. import ParamParser from '../Parser/ParamParser.js';
  4. /**
  5. * Doc Class from virtual comment node of external.
  6. */
  7. export default class ExternalDoc extends AbstractDoc {
  8. /**
  9. * apply own tag.
  10. * @private
  11. */
  12. _apply() {
  13. super._apply();
  14.  
  15. Reflect.deleteProperty(this._value, 'export');
  16. Reflect.deleteProperty(this._value, 'importPath');
  17. Reflect.deleteProperty(this._value, 'importStyle');
  18. }
  19.  
  20. /** specify ``external`` to kind. */
  21. _$kind() {
  22. super._$kind();
  23. this._value.kind = 'external';
  24. }
  25.  
  26. /** take out self name from tag */
  27. _$name() {
  28. const value = this._findTagValue(['@external']);
  29. if (!value) {
  30. log.warn('can not resolve name.');
  31. }
  32.  
  33. this._value.name = value;
  34.  
  35. const tags = this._findAll(['@external']);
  36. if (!tags) {
  37. log.warn('can not resolve name.');
  38. return;
  39. }
  40.  
  41. let name;
  42. for (const tag of tags) {
  43. const {typeText, paramDesc} = ParamParser.parseParamValue(tag.tagValue, true, false, true);
  44. name = typeText;
  45. this._value.externalLink = paramDesc;
  46. }
  47.  
  48. this._value.name = name;
  49. }
  50.  
  51. /** take out self memberof from file path. */
  52. _$memberof() {
  53. super._$memberof();
  54. this._value.memberof = this._pathResolver.filePath;
  55. }
  56.  
  57. /** specify name to longname */
  58. _$longname() {
  59. super._$longname();
  60. if (this._value.longname) return;
  61. this._value.longname = this._value.name;
  62. }
  63.  
  64. /** avoid unknown tag */
  65. _$external() {}
  66. }
  67.