www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to write document for methods under static if?

reply Yuxuan Shui <yshuiv7 gmail.com> writes:

   test type
struct A(bool T) {
	static if (T) {
		/// Case 1
		int ok(){ return 1; }
	} else {
		/// case 2
		int notok(){ return 1; }

	/// Other
	int other() { return 0; }

unittest {
	A!true x;
	A!false y;

In documents generated by ddoc, only case 1 is included. In 
documents generated by ddox, none of the cases is included.

What's the proper way to write document in this case?
Mar 10 2017
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 10 March 2017 at 12:49:42 UTC, Yuxuan Shui wrote:
 What's the proper way to write document in this case?
ddoc and ddox are both built on dmd which generates code based on the compile... so it will only show that which actually pass the static if. You might want to try my doc gen, the result is this: http://dpldocs.info/experimental-docs/test.sif.html IMPORTANT: you MUST add a module declaration with a doc comment for my thing to process it. So at the top of the file, write: /// module whatever.name.you.want; To enable generation. You can write more too, that comment creates the homepage. Anyway, if you want to try my generator, here it is: https://github.com/adamdruppe/adrdox Instructions: 1) git clone https://github.com/adamdruppe/adrdox.git 2) make 3) edit skeleton.html to customize the header text, etc. Don't change it too much, but the logo and name are easy changes. 4) Run `./doc2 yourcode.d` or `./doc2 your/project/src/dir` 5) open generated-docs/something.html in your browser It isn't perfect on static ifs, it doesn't tell you what the condition is, but it does at least generate them. let me know how it works if you decide to try it.
Mar 10 2017