react-native-navigation的迁移库

generate-js-doc.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. throw new Error('temporarily disabled, until newAPI is complete');
  2. /*
  3. const jsdoc2md = require('jsdoc-to-markdown');
  4. const fs = require('fs');
  5. const path = require('path');
  6. const BASE_DIR = './lib/src/params/';
  7. const OPTIONS_DIR = BASE_DIR + 'options/';
  8. const CONTAINERS_DIR = BASE_DIR + 'components/';
  9. const OUTPUT_DIR = './docs/docs/';
  10. const PARAMS_PARTIALS = ['./docs/templates/header.hbs', './docs/templates/sig-name.hbs'];
  11. const PARTIALS = [
  12. './docs/templates/scope.hbs',
  13. './docs/templates/docs.hbs',
  14. './docs/templates/param-table-name.hbs',
  15. '/docs/templates/linked-type-list.hbs',
  16. './docs/templates/link.hbs',
  17. './docs/templates/params-table.hbs'
  18. ];
  19. const generateMarkdownForFile = ({ file, outputDir, partial, separator }) => {
  20. const templateData = jsdoc2md.getTemplateDataSync({ files: file });
  21. const classNames = getClassesInFile(templateData);
  22. classNames.forEach((className) => createDocFileForClass({ className, templateData, outputDir, partial, separator }));
  23. };
  24. function getClassesInFile(templateData) {
  25. const classNames = templateData.reduce((classNames, identifier) => {
  26. if (identifier.kind === 'class') {
  27. classNames.push(identifier.name);
  28. }
  29. return classNames;
  30. }, []);
  31. return classNames;
  32. }
  33. function createDocFileForClass({ className, templateData, outputDir, partial = [], separator = true }) {
  34. const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`;
  35. const options = {
  36. data: templateData,
  37. template,
  38. separators: separator,
  39. 'heading-depth': 1,
  40. helper: ['./docs/linkify.js', './docs/stringify.js'],
  41. partial: [...PARTIALS, ...partial]
  42. };
  43. console.log(`rendering ${className}`);
  44. const output = jsdoc2md.renderSync(options);
  45. fs.writeFileSync(path.resolve(outputDir, `${className}.md`), output);
  46. }
  47. function inputFiles() {
  48. return [
  49. { file: './lib/src/Navigation.js', outputDir: OUTPUT_DIR },
  50. ...fs.readdirSync(OPTIONS_DIR).map((file) => {
  51. return {
  52. file: OPTIONS_DIR + file,
  53. outputDir: OUTPUT_DIR + 'options/',
  54. partial: PARAMS_PARTIALS,
  55. separator: false
  56. };
  57. }),
  58. ...fs.readdirSync(CONTAINERS_DIR)
  59. .map((file) => {
  60. return {
  61. file: CONTAINERS_DIR + file,
  62. outputDir: OUTPUT_DIR,
  63. partial: PARAMS_PARTIALS,
  64. separator: false
  65. };
  66. }),
  67. ...fs.readdirSync(BASE_DIR)
  68. .filter((file) => fs.statSync(BASE_DIR + file).isFile())
  69. .map((file) => {
  70. return {
  71. file: BASE_DIR + file,
  72. outputDir: OUTPUT_DIR
  73. };
  74. })
  75. ];
  76. }
  77. inputFiles().forEach((inputFile) => generateMarkdownForFile(inputFile)); */