Are there any tools to convert c/c++ source code to html?
Asked Answered
A

4

9

I want to a tool which can convert c/c++ source code files to HTML files. So far all tools I have found, like src-highlite, highlight, can only do syntax highlighting. The critical feature I want is to navigate over code and when my mouse moves over a classname, I can click the hyperlink and it takes me to the definition file of the class.

Then I can package these HTML files into a .mobi file, so I can read source code on my kindle.

Does anybody know?

Arel answered 24/11, 2011 at 12:38 Comment(2)
c/c++ -> html. Sounds like an oxymoron.Lyublin
To generate something like Linux Cross Reference with syntax highlight?Oke
L
14

Have you checked out Doxygen?

It will generate documentation from your comments too. There's lot of other cool features like a class graph, file dependencies graph, and of course just HTML files of the source.

For an example of the output, check out the KDE library API reference.

Linea answered 24/11, 2011 at 12:43 Comment(2)
yes! this is exactly what I want, Thank you:) In fact I ever used Doxyen about a year ago, I remind that it could embeds the whole source code along with comments into HTML.Arel
KDE API reference moved to: api.kde.org but it uses a layer on top that makes it hard to see where the Doxygen starts. doxygen.nl/results.html has a list of sample projects of which Eigen for example is more raw: eigen.tuxfamily.org/dox Here's a sample indexed file: eigen.tuxfamily.org/dox/ArithmeticSequence_8h_source.html Every cross-link links back to the doc page rather than more source however, which makes the use case of browsing source a bit annoying. Maybe there's a setting for that.Franco
A
1

check enscript: http://linux.die.net/man/1/enscript

nscript --color -Ecpp -fCourier8 *.cpp -o - |ps2pdf - output.pdf
Alwin answered 24/11, 2011 at 12:41 Comment(0)
L
1

Or use vim, open the file, and issue :TOhtml.

Lautrec answered 25/11, 2011 at 12:23 Comment(0)
F
0

Exilir https://github.com/bootlin/elixir is another option.

It is used e.g. at https://elixir.bootlin.com/linux/latest/source which indexes the Linux kernel.

Here's a sample source file: https://elixir.bootlin.com/linux/v6.7.9/source/init/main.c#L230 If you try clicking some definitions you can quickly jump to possible definitions and reference lists.

From the project README:

Elixir is a source code cross-referencer inspired by LXR. It’s written in Python and its main purpose is to index every release of a C or C++ project (like the Linux kernel) while keeping a minimal footprint.

It uses Git as a source-code file store and Berkeley DB for cross-reference data. Internally, it indexes Git blobs rather than trees of files to avoid duplicating work and data. It has a straightforward data structure (reminiscent of older LXR releases) to keep queries simple and fast.

https://elixir.bootlin.com/linux/latest/source was previously mentioned by Franklin Yu on a comment.

Franco answered 7/3 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.