Reference Source Test

src/Doc/FileDoc.js

  1. import fs from 'fs';
  2. import AbstractDoc from './AbstractDoc.js';
  3.  
  4. /**
  5. * Doc Class from source file.
  6. */
  7. export default class FileDoc 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 ``file`` to kind. */
  21. _$kind() {
  22. super._$kind();
  23. this._value.kind = 'file';
  24. }
  25.  
  26. /** take out self name from file path */
  27. _$name() {
  28. super._$name();
  29. this._value.name = this._pathResolver.filePath;
  30. }
  31.  
  32. /** specify name to longname */
  33. _$longname() {
  34. this._value.longname = this._pathResolver.fileFullPath;
  35. }
  36.  
  37. /** specify file content to value.content */
  38. _$content() {
  39. super._$content();
  40.  
  41. const filePath = this._pathResolver.fileFullPath;
  42. const content = fs.readFileSync(filePath, {encode: 'utf8'}).toString();
  43. this._value.content = content;
  44. }
  45. }