Gustavo Niemeyer wrote:
Why don't you use macro which only takes the name of the static array and the doc-string itself as argument ? This could then be expanded to whatever needs to be done for a particular case/platform, e.g.
Py_DefineDocString(foo__doc__, "foo does bar");
(I use such an approach in the mx stuff and it works great.)
Yes, it's a nice idea!
I'm looking for some way to "discard" the string using a macro. Let me explain with code:
[...] #define Py_DOCSTR(name, str) static char *name = str #ifdef WITH_DOC_STRINGS #define Py_DOCSTR_START(name) Py_DOCSTR(name,) #define Py_DOCSTR_END ; #else #define Py_DOCSTR_START(name) Py_DOCSTR(name, ""); /* Also discards what follows somehow */ #define Py_DOCSTR_END /* Stop discarding */ #endif [...]
This would make it possible to do something like this:
Py_DOCSTR(simple_doc, "This is a simple doc string.");
...and also...
Py_DOCSTR_START(complex_doc) "This is a complex doc string" #ifndef MS_WIN16 "like the one in sysmodule.c" #endif "Something else" Py_DOCSTR_END
This seems to be the most elegant way to allow these complex strings. But unfortunately, I haven't found any way so far to do this "discarding thing", besides including another "#if" in the documentation itself.
Any good ideas?
Wouldn't it be much simpler to wrap the complete Py_DOCSTR() into #ifdefs ? BTW, I don't we'll ever need to #ifdef doc-strings for platforms; you can just as well put the information for all platforms into the doc-string -- after the recipient is a human with enough non-AI to parse the doc-string into meaningful sections ;-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/