简体   繁体   中英

How to generate documentation in RTF from Javascript

I am currently trying to generate RTF documentation for HTML, JavaScript, and CSS files in a project, as I can do from Doxygen in the Java part of the project.

Javascript files are JSDoc commented, but I can change that to other format easily.

I am aware of JSDoc, ESDoc and YUIDoc. All of them generate HTML, although not all of them work well, YUIDoc, for example, skipped a lot of files due to filename problems. It seems that none of them deals with CSS files (or HTML).

I am also aware of pandocs. I imagine that is possible using JSDoc or ESDoc to generate HTML and them convert to RTF via Pandoc, but didn´t manage to do it yet.

Any other solutions? Anyone already did it?

Even a partial solution, such as only Javascript, will help.

You can maintain your workflow with Doxygen and still document javascript files using a proper filter and minor changes in your configuration file.

The Doxygen manual cites js2doxy.pl as a Perl script to help in js documentation but also alerts that the original author's page is currently unachievable.

You should find help in the filter at this link: https://gist.github.com/sarnold/d6294abab8fb573fc49069de62fc549a

If you choose to use that link's filter, you will need node.js installed in order to run it. But you can choose to develop your own filter.

After you choose your filter you need to change your Doxygen config file to find and process javascript files.

Find the FILE_PATTERNS control tag in your original config file and adjust its value:

FILTER_PATTERNS =*.js=doxygen.js

Where doxygen.js must be the path to the desired javascript filter.

Find the FILE_PATTERNS control tag and include *.js among the terminations listed.

Change the INPUT tag to point to your source folder.

Finally, comment the js file using the patterns suitable to the filter. The doxygen.js filter uses the \\\\\\ @ style before functions and namespaces as in the following example:

/// @file Sync.js
/// @namespace Sync
/// Module for loading and storing data

var Sync = {
    /// @function Sync.load
    /// Loads an resource
    /// @param {String} id the GUID of the resource
    /// @param {Function} success callback to be executed with the data on suceess
    /// @param {Function} error callback to be executed with error description in case of failure
    /// Loads an resource
    load : function (id, success, error) {
    },
}

After that, you can run Doxygen and generate RTF like in the Java part of your project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM