code: function doc(pkgName, pkgVersion) {
      const typedoc = require("typedoc");
      const typescriptOptions = require(path.resolve("./build/tsconfig.es5-commonjs.json")).compilerOptions;
      const typedocOptions = require(path.resolve("./build/typedoc.js"));
  
      // Add version number to header of generated HTML documentation
      typedocOptions.name = pkgName + " v" + pkgVersion;
  
      const app = new typedoc.Application(Object.assign(typedocOptions, typescriptOptions));
  
      // A path to source files can only be specified on the command line, 
      // in the API we have to specify individual source files.
      // Note that the "exclude" option pattern is also not considered in API code.
      const srcFiles = [];
      getTypedocModuleSources(path.resolve(typedocOptions.src), srcFiles);
      getTypedocModuleSources(path.resolve(typedocOptions.src, "db/adapters/"), srcFiles);
  
      rimraf.sync(path.resolve("./" + typedocOptions.out));
  
      logInfo("Generate HTML documentation from source code...");
      const success = app.generateDocs(srcFiles, typedocOptions.out);
      if (!success) {
          logError("Failed to generate HTML documentation");
      }
  
      function getTypedocModuleSources(srcPath, srcFiles) {
          fse.readdirSync(srcPath).forEach((file, index) => {
              let filePath = path.join(srcPath, file);
              if (!fse.lstatSync(filePath).isDirectory()) {
                  if (path.extname(filePath) === ".ts") {
                      srcFiles.push(filePath);
                  }
              }
          });
      }
  }
docs: Generate API documentation from source code (using typedoc generator)