config.js 748 B

123456789101112131415161718192021
  1. const path = require('path');
  2. const fs = require('fs');
  3. /** @type import('solidity-docgen/dist/config').UserConfig */
  4. module.exports = {
  5. outputDir: 'docs/modules/api/pages',
  6. templates: 'docs/templates',
  7. exclude: ['mocks'],
  8. pageExtension: '.adoc',
  9. pages: (_, file, config) => {
  10. // For each contract file, find the closest README.adoc and return its location as the output page path.
  11. const sourcesDir = path.resolve(config.root, config.sourcesDir);
  12. let dir = path.resolve(config.root, file.absolutePath);
  13. while (dir.startsWith(sourcesDir)) {
  14. dir = path.dirname(dir);
  15. if (fs.existsSync(path.join(dir, 'README.adoc'))) {
  16. return path.relative(sourcesDir, dir) + config.pageExtension;
  17. }
  18. }
  19. },
  20. };