I am using JS Doc version 3 (https://github.com/jsdoc3/jsdoc). When I run the tool, by default it generates documentation in HTML format. Is it possible to generate doc in PDF format?
I would suggest you look at jsPDF. It is pretty cool and easy to use.
The code you download from the mentioned side contains reach examples.
What is jsPDF: A HTML5 client-side solution for generating PDFs. Perfect for event tickets, reports, certificates, you name it!
For example to generate pdf of html, just write following code.
var doc = new jsPDF();
// We'll make our own renderer to skip this editor
var specialElementHandlers = {
'#editor': function(element, renderer){
return true;
}
};
// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML($('body').get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
This is a snapshot of the sample page jsPDF that you get in your download. It contains different example types, codes and pdf generation example.
Currently there is no tool for converting jsdoc directly to PDF, but you can convert it to some intermediate format (markdown in this example), and then convert it to PDF:
Install required tools
$ npm install -g markdown-pdf $ npm install -g jsdoc-to-markdown
Generate single markdown file with documentation
$ jsdoc2md path/to/your/code/** > docs.md
Convert markdown file to PDF:
$ markdown-pdf docs.md
You can change how documentation looks using css stylesheets (here you can find an example stylesheet).
you got html files now, there are so many tools to convert html to pdf (i assume you use node.js)
© 2022 - 2024 — McMap. All rights reserved.