5

I am trying to use some Doxygen filter for Visual Basic in Windows.

I started with Vsevolod Kukol filter, based on gawk. There are not so many directions. So I started using his own commented VB code VB6Module.bas and, by means of his vbfilter.awk, I issued:

gawk -f vbfilter.awk VB6Module.bas  

This outputs a C-like code on stdin. Therefore I redirected it to a file with:

gawk -f vbfilter.awk VB6Module.bas>awkout.txt

I created this Doxygen test.cfg file:

PROJECT_NAME      = "Test"
OUTPUT_DIRECTORY  = test
GENERATE_LATEX    = NO
GENERATE_MAN      = NO
GENERATE_RTF      = NO
CASE_SENSE_NAMES  = NO
INPUT             = awkout.txt
QUIET             = NO
JAVADOC_AUTOBRIEF = NO
SEARCHENGINE      = NO

To produce the documentation I issued:

doxygen test.cfg 

Doxygen complains as the "name 'VB6Module.bas' supplied as the second argument in the \file statement is not an input file." I removed the comment @file VB6Module.bas from awkout.txt. The warning stopped, but in both cases the documentation produced was just a single page with the project name.

I tried also the alternative filter by Basti Grembowietz in Python vbfilter.py. Again without documentation, again producing errors and without any useful output.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
antonio
  • 10,629
  • 13
  • 68
  • 136

2 Answers2

2

After trials and errors I solved the problem.

I was unable to convert a .bas file in a format such that I can pass it to Doxygen as input. Anyway, following @doxygen user suggestions, I was able to create a Doxygen config file such that it can interpret the .bas file comments properly.

Given the file VB6Module.bas (by the Doxygen-VB-Filter author, Vsevolod Kukol), commented with Doxygen style adapted for Visual Basic, I wrote the Doxygen config file, test.cfg, as follows:

PROJECT_NAME      = "Test"
OUTPUT_DIRECTORY  = test
GENERATE_LATEX    = NO
GENERATE_MAN      = NO
GENERATE_RTF      = NO
CASE_SENSE_NAMES  = NO
INPUT             = readme.md VB6Module.bas
QUIET             = YES
JAVADOC_AUTOBRIEF = NO
SEARCHENGINE      = NO
FILTER_PATTERNS   = "*.bas=vbfilter.bat"

where:

  • readme.md is any Markdown file that can used as the main documentation page.
  • vbfilter.bat contains:

    @echo off gawk.exe -f vbfilter.awk "%1%"

  • vbfilter.awk by the filter author is assumed to be in the same folder as the input files to be documented and obviously gawk should be in the path.

Running:

doxygen test.cfg 

everything is smooth, apart two apparently innocuous warnings:

gawk: vbfilter.awk:528: warning: escape sequence `\[' treated as plain `[' 
gawk: vbfilter.awk:528: warning: escape sequence `\]' treated as plain `]' 

Now test\html\index.html contains the proper documentation as extracted by the ".bas" and the Markdown files.

antonio
  • 10,629
  • 13
  • 68
  • 136
  • Does this work for `.cls` files too? Or does this only work for procedural code? – Stefan Falk Jul 21 '14 at 15:56
  • @StefanFalk: I haven't tried (or I did and forgot). Anyway, for sure `vbfilter.awk` accepts and parses `.cls` and, by updating the config file with `.cls` files, you can pass the filtered input to doxygen. Then I don't know if any specific issue might arise. – antonio Jul 21 '14 at 16:57
  • Okay thank you. I've tried it and it parses of course but the problem is that a single folder is treated as `package` that contains all functions after running doxygen. That means functions from `ModuleName.bas` and `ClassName.cls` will be thrown together. A simple solution might be moving all files into seperate folders and same named. This would create separate documentations for each file and a function entry e.g. would look like `Public ClassName.FunctionName() As Integer`. – Stefan Falk Jul 22 '14 at 09:50
  • Please share your solution as an answer if you find one – antonio Jul 22 '14 at 15:27
1

Alright I did some work:

You can download this .zip file. It contains:

  • MakeDoxy.bas The macro that makes it all happen
  • makedoxy.cmd A shell script that will be executed by MakeDoxy
  • configuration Folder that contains doxygen and gawk binaries which are needed to create the doxygen documentation as well as some additional filtering files which were already used by the OP.
  • source Folder that contains example source code for doxygen

How To Use:

Note: I tested it with Excel 2010

  1. Extract VBADoxy.zip somehwere (referenced as <root> from now on)

  2. Import MakeDoxy.bas into your VBA project.
    You can also import the files from source or use your own doxygen-documented VBA code files but you'll need at least one documented file in the same VBA project.

    enter image description here
  3. Add "Microsoft Visual Basic for Applications Extensibility 5.3" or higher to your VBA Project References (did not test it with lower versions). It's needed for the export-part (VBProject, VBComponent).

    enter image description here

  4. Run macro MakeDoxy

What is going to happen:

  1. You will be asked for the <root> folder.
  2. You will be asked if you want to delete <root>\source afterwards
    It is okay to delete those files. They will not be removed from your VBA Project.
  3. MakeDoxy will export all .bas, cls and .frm files to location:
    <root>\source\<modulename>\<modulename>(.bas|.cls|.frm)
  4. cmd.exewill be commanded to run makedoxy.cmd and delete <root>\source if you've chosen that way which alltogether will result in your desired documentation.

A logfile MakeDoxy.bas.logwill be re-created each time MakeDoxy is executed.

You can play with configuration\vbdoxy.cfg a little if you want to change doxygens behavior.

There is still some room for improvements but I guess this is something one can work with.

Community
  • 1
  • 1
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • +1 nice work, I have not VB handy now but will test it as soon as I can. – antonio Jul 23 '14 at 15:01
  • Alright :) I think it's still not perfect but now it does not throw together the modules. Maybe this could also be prevented by changing the doxy .cfg file but I didn't find anything yet. But this way one can use it as a "export all module files at once"-tool too :D – Stefan Falk Jul 23 '14 at 15:04
  • The link to the zip file is broken. [this .zip file][1] [1]: https://dl.dropboxusercontent.com/u/30731675/VBADoxy.zip – Adolfo Correa Jul 01 '17 at 05:06
  • @displayname Hi, sorry to bother you with this, but would it be possible to re-upload the Zip File or edit the answer to copy it's actual contents (at least the feasible parts) into the answer? – L8n Mar 05 '19 at 09:56
  • @L8n Sorry but I'm afraid I do not have this file anymore. – Stefan Falk Mar 05 '19 at 16:54