@informalsystems/quint
Version:
Core tool for the Quint specification language
75 lines (73 loc) • 2.46 kB
JavaScript
;
/* ----------------------------------------------------------------------------------
* Copyright 2023 Informal Systems
* Licensed under the Apache License, Version 2.0.
* See LICENSE in the project root for license information.
* --------------------------------------------------------------------------------- */
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMarkdown = exports.produceDocsById = exports.produceDocs = void 0;
/**
* Assembling of documentation strings collected from the Quint IR,
* previously parsed from documentation comments starting with ///
*
* @author Gabriela Moreira
*
* @module
*/
const IRprinting_1 = require("./ir/IRprinting");
const quintIr_1 = require("./ir/quintIr");
/**
* Produces a documentation map for the modules' definitions
*
* @param quintModule the module for which documentation should be produced
* @returns a map of definition names to their documentation
*/
function produceDocs(quintModule) {
const entries = quintModule.declarations.filter(quintIr_1.isDef).map(def => {
const entry = [
def.name,
{
name: def.name,
signature: (0, IRprinting_1.declarationToString)(def, false),
documentation: def.doc,
},
];
return entry;
});
return new Map(entries);
}
exports.produceDocs = produceDocs;
/**
* Produces a documentation map for the modules' definitions
*
* @param quintModule the module for which documentation should be produced
* @returns a map of definition ids to their documentation
*/
function produceDocsById(quintModule) {
const entries = quintModule.declarations.filter(quintIr_1.isDef).map(def => {
const entry = [
def.id,
{
name: def.name,
signature: (0, IRprinting_1.declarationToString)(def, false),
documentation: def.doc,
},
];
return entry;
});
return new Map(entries);
}
exports.produceDocsById = produceDocsById;
/**
* Formats a documentation entry to Markdown
*
* @param entry the documentation entry to be formatted
* @returns a string with the entry's label as header and documentation as body
*/
function toMarkdown(entry) {
return `## ${entry.name}
Signature: \`${entry.signature}\`
${entry.documentation || ''}`;
}
exports.toMarkdown = toMarkdown;
//# sourceMappingURL=docs.js.map