readme.js 553 B

123456789101112131415161718192021222324
  1. /**
  2. * Make the contents of a README file available to include in the output.
  3. * @module jsdoc/readme
  4. */
  5. const env = require('jsdoc/env');
  6. const fs = require('jsdoc/fs');
  7. const markdown = require('jsdoc/util/markdown');
  8. /**
  9. * Represents a README file.
  10. */
  11. class ReadMe {
  12. /**
  13. * @param {string} path - The filepath to the README.
  14. */
  15. constructor(path) {
  16. const content = fs.readFileSync(path, env.opts.encoding);
  17. const parse = markdown.getParser();
  18. this.html = parse(content);
  19. }
  20. }
  21. module.exports = ReadMe;