Code2Web is a set of utilities and classes that convert source code (Java, JavaScript, HTML) into HTML. It is the successor of the java2web set, which was limited to the java language. Unlike its predecessor, Code2Web is designed so that new language definitions can be added on the fly.
Ok, what's different from the gazillion other similar tools?
I wrote Code2Web in about a week for my personal needs - publishing tutorials with source code on the web. A tutorial with source code is different from dumping your sorce on the web with some pretty styles. Some irrelevant parts of the code may need to be hidden. Some others - highlighted. Specific links at specific points must be inserted to other resources on the web - be them javadocs, other source files, or whatever. I might need to annotate a part of the code to illustrate a point.
So why don't use a standard Java 2 HTML converter and then perform the edits by hand? Well, because if there is one thing that I hate is the double-maintenance problem : having to remember - each time when I change a source code - that I must change something else somewhere in order to keep them in sync. So I needed a tool that would allow me to do all those things in one step without having to store the final result.
So Code2Web has currently the following features:
Here are some examples of the generated code:
If you are a developer wishing to generate HTML from the source code on the fly, you can use the HTMLConverter class to handle the conversion and manipulate all options programmatically
If you are an end-user wishing to convert some source code to HTML using a command-like program, you can use the included code2web program to perform the conversion. All options are set from the command line.
If you are a web designer wishing to convert on the fly source code to HTML and embed it in a pre-existing design, you can use the included JSP Tag . However, this requires a Servlet/JSP compatible server.
Code2Web was developed using the excellent JavaCC parser-generator. For the full docs see the usage.