I'm trying to generate a documentation in pdf in my react / typescript project, but I didn't find any lib that generate the documentation in PDF.
I'm using typedoc to generate the documentation right now, but typedoc don't have options to generate in PDF.
I tried to convert HTML generated from typedoc to pdf, but there is some problems with that. 1 - The pdf out put dont looks good. 2 - There is many html files documented to convert.
SO, is there a way to generate a react / typescript documentation in PDF?
CodePudding user response:
There are a few libraries and tools that can be used to generate documentation in PDF format from a React/TypeScript project. Some of them are:
JSDoc: JSDoc is a popular documentation generation tool for JavaScript. It can be used to generate documentation in PDF format using the jsdoc-to-markdown and markdown-pdf packages.
YUIDoc: YUIDoc is another popular documentation generation tool for JavaScript. It can also be used to generate documentation in PDF format using the yuidoc-pdf package.
doxdox: Doxdox is a documentation generation tool that can be used to generate documentation in PDF format. It supports TypeScript and can be integrated with a React project.
Docsify: Docsify is a documentation generation tool that can be used to generate documentation in PDF format. It can be configured to process TypeScript files and can be integrated with a React project.
LaTeX: LaTeX is a document preparation system that can be used to generate documentation in PDF format. You can write your documentation in LaTeX and then use a tool like pdflatex to convert it to PDF.
It is worth noting that, in general, generating PDFs from HTML is not an easy task, and the result is not always optimal. The best approach is to use a tool that specifically generates PDFs.
CodePudding user response:
If you have html output you can convert it to pdf using pandoc. Provide it print friendly css (I like Gutenberg).
For example:
pandoc -o input.html -t output.pdf --css styles.css
Problem with this approach is that css supported by various pandoc engines is quite outdated.
Alternatively provide print friendly css to your html file using <link>
tags, open in browser and press Ctrl P
to print it. Print styles will be applied. I usually use this option, since support for modern-ish css is better.
Problem of many html files can easily be solved by pandoc. To merge all html files in current directory use:
pandoc -s *.html -o output.html
If document still doesn't look good tweak css stylesheet. Consult Paged media docs at MDN.