Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

building the API documentation from source

Moderators: larsivi kris

Posted: 03/09/09 18:37:29

I'm interested in creating a local copy of the API documentation. It seems that candydoc is used for the Tango API docs, but there is no information on how to use actually build the docs. How would I build the Tango API docs from source using DMD?

Author Message

Posted: 03/09/09 20:58:18

Hmmm, well it looks like some kind of specialized build process is used on the dsource trac server to build the docs. The good news I discovered is that we can build our own with "dsss build --doc". The bad news is that each API page is in a subfolder (like tango/core), and these don't correlate to the depth of the package (for example tango.core.sync.Barrier in just "Barrier.html" in the tango/core folder). Another bad thing is that a handy "Package" tab is in the outline view, but the links are useless because they aren't named properly. On the plus side, the candydoc generation seems to be a little nicer than what's on the actual site.

So to fix this, I wrote a tiny D program that renames each html file to the name corresponding to it's package name, which matches what is online and what the Package tab wants. There are probably lots of better ways to do this, but here it is:

import tango.io.File;
import tango.io.FileScan;
import tango.io.Stdout;
import Text = tango.text.Util;

void main()
{
  auto scan = new FileScan;
  scan(".", ".html");

  foreach(file; scan.files)
  {
    auto content = cast(char[]) File(file.toString()).read;

    foreach(line; Text.lines(content))
      if(Text.containsPattern(line, "<title>"))
      {
        auto dotname = line[7 .. line.length - 8]; 
        Stdout.formatln("Renaming {} to {}.html", file, dotname).newline;
        file.rename(dotname ~ ".html");
        break;
      }
  }
}

This should be place in and run from the dsss_docs folder that is created when the "dsss build --doc" command is used. One other thing that should be done after it's finished is to go into one of the subfolders, like dsss_docs/tango/core, and copy the candydoc folder into the top dsss_docs folder. Without that step the pages will look awful, and you won't get the nice outline and package tree. I should probably add that into the program, along with an index page. Anyway, the result is pretty and handy (and pretty handy :)

Posted: 03/09/09 22:34:30

Hi obijohn,

we are more or less phasing out the doc gen by dmd since dmd sucks at it. Currently the future looks like dil, and the necessary support files is recently checked into trunk.

If you have a recent dil installed, you should be able to use the tango_doc.py script. FWIW, once we get stuff running, there will also be downloadable docs.

Posted: 03/10/09 18:33:30 -- Modified: 03/10/09 18:34:48 by
obijohn -- Modified 2 Times

Larsivi,

That's good news. However, if dil is going to be used to generate the current Tango source API, it should really be updated to compile with the current Tango trunk. For example, Print!() is now FormatOutput?!(), but that's just one breaking change. The next roadblock for me was isUniAlpha(), at which point I stopped trying to get it to compile since I couldn't find something easy to search-and-replace it with. It seems ironic that building the tool the current Tango trunk uses (or will use) to generate the docs actually requires an old release of Tango to compile it.

Also, the tango_doc.py script evidently requires Python 2.5. Since 2.6 is the "current production version" for the 2.x line, it should really be supported, especially considering that a developer using the current Tango trunk is also probably using the most recent 2.x Python. Not that it matters, since I can't get dil to compile anyway.

Anyway, it's nice that the API doc generation is still being worked on, since it's a highly valuable tool for users of the library. Now that I re-read what I just wrote, it looks like I'm being overly critical. Please just take it as a couple of suggestions as you move towards this new doc generation system.

Posted: 03/10/09 19:39:50

dil isn't my project so I can't control that, but I believe there is a patch to make it compilable with current Tango trunk. As for tango_do.py, feel free to suggest a patch that will make it 2.6 compatible, but it still needs to work with 2.5 since that is what is used for stuff generated for the web site.

Posted: 03/11/09 23:38:13

Hi obijohn,

You wrote in my channel, but I noticed that only on the next day, sorry.

Regarding compiling dil and Tango: I haven't upgraded to Tango 0.9.8 yet, because I'm not motivated enough to compile Tango myself atm. However, I will try to make the code compilable with .7 and .8. I don't know why you have problems with isUniAlpha. Do you get compiler or linker errors?

Regarding Python: Sounds like I should upgrade to 2.6. I'm not sure but the scripts should work with 2.6 as well.

Posted: 03/14/09 16:26:49

Aziz wrote:

Hi obijohn,

You wrote in my channel, but I noticed that only on the next day, sorry.

Regarding compiling dil and Tango: I haven't upgraded to Tango 0.9.8 yet, because I'm not motivated enough to compile Tango myself atm. However, I will try to make the code compilable with .7 and .8. I don't know why you have problems with isUniAlpha. Do you get compiler or linker errors?

I found the patch which updates dil to compile with the current tango trunk, and it compiled fine after applying it.

Regarding Python: Sounds like I should upgrade to 2.6. I'm not sure but the scripts should work with 2.6 as well.

There does seem to be a problem for me with the tango_doc.py script (I haven't tried the others). I downgraded my Python install to 2.5.4 just to be on the safe side, but the script still throws the same error. It could be that it is assuming something about the environment or OS that doesn't fit with mine (OS X) and the error isn't actually caused by the line shown. Anyway, here's the error I get:

  File "scripts/tango_doc.py", line 32
    revision = "?rev=" + revision if revision != None else ''
                                   ^
SyntaxError: invalid syntax

I'm running some fairly large (wx)Python programs, so I don't think there's a problem with my Python installation. Like I said, my guess is that it may be environment or OS related, but that's just a guess.

Posted: 03/16/09 02:19:29

  File "scripts/tango_doc.py", line 32
    revision = "?rev=" + revision if revision != None else ''
                                   ^
SyntaxError: invalid syntax

I suspect that you have multiple Python installations on your Mac, and you are somehow using one older than 2.5. (The ternary operator is added in Python 2.5.) With Python 2.2.2, I get the same SyntaxError: invalid syntax error.

-- MIURA Masahiro echochamber@gmail.com

Posted: 03/19/09 21:22:18

Dubhead wrote:

I suspect that you have multiple Python installations on your Mac, and you are somehow using one older than 2.5. (The ternary operator is added in Python 2.5.) With Python 2.2.2, I get the same SyntaxError: invalid syntax error.

-- MIURA Masahiro echochamber@gmail.com

Funny thing, the script begins with "#!/usr/bin/python" which on my system runs 2.3 (I was advised against trying to remove it). The default python used by GUI apps is 2.5, and it is installed in /usr/local/bin (which comes before /usr/bin in my PATH). Anyway, starting the script with "python scripts/tango_doc.py [tango_loc] [doc_dir]" certainly gets past the python error. However, I can't seem to find any configuration for dil that will actually work. The latest error I get is:

/../data//lang_en.d(1,1)S: variable 'messages' is not defined

Until there's a clear-cut explanation of how to set up dil and use tango_doc.py, I'll just sit back and wait now.