From: Ian B. <ia...@co...> - 2003-01-17 19:26:36
|
I'm working with the Webware project (webware.sf.net), and we really need some cohesive reference documentation, aimed particularly at the public interfaces. I'm wondering if anyone is using docutils for this now... if so, I'd like to see how it's working. It's not entirely clear to me what docutils status is (I've used reST a lot, but not much else). Some options I've considered, in order of complexity: * Writing the whole thing in reST, separate from the code itself. The writing wouldn't be so bad, but the maintenance would be more difficult. * Splitting it up into modules, and putting the entire reference documentation in the module docstring. * Using internal references in those docstrings, so I could effectively include the docstrings from other portions of code (classes, methods, etc). One thing I *don't* like is reference documentation in the style of pydoc. To me it's too automatic, and generally too hard to follow. I find reference documentation with some framework of text (lead-in paragraphs, categorization, etc) to be much better. There are also methods which, while "public" aren't actually useful, and I don't think those should be documented -- they are just distracting. So the last option is the one I like the most. But I doubt it's in place. I've already decided I'm not going to get the reference documentation done for the next release (there's other documentation that needs to be written, and documentation is tiring :), so I don't plan to use this in the short term and I could put some work into producing a system I like. My vision for a docstring-based reference documentation would probably look like: """ Module ====== This module does X, Y, Z. Most work will be done through the class: .. docstring:: MainClass In certain cases you may wish to access the functionality separately, yada yada yada, and may wish to use: .. docstring:: some_function .. docstring:: some_other_function """ class MainClass: """ Recursively we continue, now with methods: .. docstring:: MainClass.some_method """ How far away might this be? Are there better alternatives already in place, or planned on? Does someone experienced in writing reference documentation think this is the wrong way to go about it? -- Ian Bicking Colorstudy Web Development ia...@co... http://www.colorstudy.com PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7 4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241 |
From: David G. <go...@py...> - 2003-01-18 16:32:22
|
I'm copying this to docutils-develop, a more appropriate venue for the discussion IMO. Subscribe at <http://lists.sf.net/lists/listinfo/docutils-develop>. Ian Bicking wrote (quoted in full): > I'm working with the Webware project (webware.sf.net), and we really > need some cohesive reference documentation, aimed particularly at > the public interfaces. I'm wondering if anyone is using docutils > for this now... if so, I'd like to see how it's working. It's not > entirely clear to me what docutils status is (I've used reST a lot, > but not much else). Are you referring to "auto-documentation" (extracting documentation from source code)? I have begun work on a Python Source Reader component which will accomplish this. The code so far is in docutils/readers/python/moduleparser.py. The plan is described in PEP 258 (<http://docutils.sf.net/spec/pep-0258.html>), <http://docutils.sf.net/spec/pysource.html>, and <http://docutils.sf.net/spec/notes.html#python-source-reader>. > Some options I've considered, in order of complexity: > * Writing the whole thing in reST, separate from the code itself. > The writing wouldn't be so bad, but the maintenance would be more > difficult. This can be done now of course. > * Splitting it up into modules, and putting the entire reference > documentation in the module docstring. The Python Reader package doesn't extract docstrings yet. I'm currently concentrating on finding a new job [#]_, which means I don't know how much time I'll be able to devote to this. .. [#] Check out my resume at <http://starship.python.net/~dgoodger/cv/>! Please tell your friends, relatives, neighbors, managers, and HR people! Let me know if you have any leads. Thanks! > * Using internal references in those docstrings, so I could > effectively include the docstrings from other portions of code > (classes, methods, etc). I hadn't thought of that approach. From your description, it seems to require a lot of bookkeeping and redundancy, which I wouldn't want to write or require others to write. But I encourage you to explore it. > One thing I *don't* like is reference documentation in the style of > pydoc. To me it's too automatic, and generally too hard to follow. I hope that Docutils' auto-documentation will be more flexible than pydoc's, although it will have the same basis. It will certainly have more flexible rendering, and I hope much more readable. > I find reference documentation with some framework of text (lead-in > paragraphs, categorization, etc) to be much better. That can be tricky. One idea I had (documented in the spec/notes file) is to recognize JavaDoc-style documentation comments almost anywhere in the code. This would allow a more "literate programming" approach than what pydoc provides. > There are also > methods which, while "public" aren't actually useful, and I don't > think those should be documented -- they are just distracting. How could software tell the difference? If we can come up with an unobtrusive way to tell the docstring processing system to disregard certain methods, it could be useful. Maybe a class attribute equivalent of the "__all__" module attribute? Or perhaps the opposite: a "__none__" class attribute ;). > So the last option is the one I like the most. But I doubt it's in > place. Correct, it's not. > I've already decided I'm not going to get the reference > documentation done for the next release (there's other documentation > that needs to be written, and documentation is tiring :), so I don't > plan to use this in the short term and I could put some work into > producing a system I like. Glad for the help! > My vision for a docstring-based reference documentation would > probably look like: > > """ > Module > ====== > > This module does X, Y, Z. Most work will be done through the class: > > .. docstring:: MainClass > > In certain cases you may wish to access the functionality > separately, yada yada yada, and may wish to use: > > .. docstring:: some_function > .. docstring:: some_other_function > """ > > class MainClass: > """ > Recursively we continue, now with methods: > > .. docstring:: MainClass.some_method > """ I envision something more along the lines of this:: """ A general description of the highlights of the module, with references (interpreted text) to the details. We don't need a "Module" title because it will be derived automatically. This module does X, Y, Z. Most work will be done through the `MainClass` class. In certain cases you may wish to access the functionality separately, yada yada yada, and may wish to use `some_function` or `some_other_function` """ class MainClass: """ Description of this class, with references to specific methods like `some_method`. We don't need to fully qualify (no "MainClass." prefix) because "some_method" is in the local namespace. """ ## # My idea from JavaDoc is to allow document comments # interspersed in the code in some way, which will # interleave with the code objects and docstrings. # These would include section titles, allowing a # subdivision of methods by category. For example: ## # Magic Methods # ============= def __str__(self): """String representation of this object (pseudo-XML).""" ... > How far away might this be? A function of my spare time and volunteer contributions. Hint hint. > Are there better alternatives already in place, or planned on? Alternative software packages? There's HappyDoc, EpyDoc, effbot's PythonDoc, and lots of older stuff too; see PEP 256. None use reStructuredText though. > Does someone experienced in writing > reference documentation think this is the wrong way to go about it? ISTM that there's a built-in limit to the potential quality of auto-documentation. It may not lend itself to a more narrative or free-form style. However, I hope that Docutils will be a platform for experimentation. That's why I'm keeping the processing stages separate and well-defined. See <http://article.gmane.org/gmane.text.docutils.devel/139> and the thread starting with <http://article.gmane.org/gmane.text.docutils.devel/118>. -- David Goodger http://starship.python.net/~goodger Projects: * Python Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html) * The Go Tools Project: http://gotools.sourceforge.net/ |
From: David G. <go...@py...> - 2003-01-18 18:06:07
|
Sorry, mistyped the URL. It should be <http://starship.python.net/~goodger/cv/>. Thanks again! -- David Goodger http://starship.python.net/~goodger |
From: Ian B. <ia...@co...> - 2003-01-18 20:47:45
|
On Sat, 2003-01-18 at 10:34, David Goodger wrote: > > I'm working with the Webware project (webware.sf.net), and we really > > need some cohesive reference documentation, aimed particularly at > > the public interfaces. I'm wondering if anyone is using docutils > > for this now... if so, I'd like to see how it's working. It's not > > entirely clear to me what docutils status is (I've used reST a lot, > > but not much else). > > Are you referring to "auto-documentation" (extracting documentation > from source code)? I have begun work on a Python Source Reader > component which will accomplish this. The code so far is in > docutils/readers/python/moduleparser.py. The plan is described in PEP > 258 (<http://docutils.sf.net/spec/pep-0258.html>), > <http://docutils.sf.net/spec/pysource.html>, and > <http://docutils.sf.net/spec/notes.html#python-source-reader>. Yes, I'm thinking of auto-documentation, or at least documentation with an automated step. > The Python Reader package doesn't extract docstrings yet. I'm > currently concentrating on finding a new job [#]_, which means I don't > know how much time I'll be able to devote to this. > > .. [#] Check out my resume at > <http://starship.python.net/~dgoodger/cv/>! Please tell your > friends, relatives, neighbors, managers, and HR people! Let me > know if you have any leads. Thanks! You're in Canada, right? My scant connections don't go as far as Canada, but who knows... > > * Using internal references in those docstrings, so I could > > effectively include the docstrings from other portions of code > > (classes, methods, etc). > > I hadn't thought of that approach. From your description, it seems to > require a lot of bookkeeping and redundancy, which I wouldn't want to > write or require others to write. But I encourage you to explore it. It's about the same amount of bookkeeping that you'd need to create a high-quality reference document (like the Python module documentation, for instance). It should be about as difficult to write. The advantage would be entirely in the maintenance, by having code and documentation next to each other. Some of the bookkeeping might be possible to ease -- for instance, keeping track of methods that aren't included and giving a warning (so you don't forget to include documentation you wrote). Or maybe have a directive that would just include all the documentation of the class or module -- either ordered like in the source, or ordered alphabetically. > > One thing I *don't* like is reference documentation in the style of > > pydoc. To me it's too automatic, and generally too hard to follow. > > I hope that Docutils' auto-documentation will be more flexible than > pydoc's, although it will have the same basis. It will certainly have > more flexible rendering, and I hope much more readable. > > > I find reference documentation with some framework of text (lead-in > > paragraphs, categorization, etc) to be much better. > > That can be tricky. One idea I had (documented in the spec/notes > file) is to recognize JavaDoc-style documentation comments almost > anywhere in the code. This would allow a more "literate programming" > approach than what pydoc provides. If everything is ordered like in the source, perhaps a comment (or plain string) could be parsed out as in-between text. Like: """ These functions are all dangerous: """ def yadayada(): "docs for this" And so on... they could appear in class definitions as well. That they are strings implies they are different than mere comments -- most of the comments I write are intended to be read by someone reading the code, and I have no desire to separate them into documentation; I'd be willing to make that distinction strict in the code I work with. But that's harder to work with than inclusion, because your narrative is split up all over the place with lots of code in between. > > There are also > > methods which, while "public" aren't actually useful, and I don't > > think those should be documented -- they are just distracting. > > How could software tell the difference? If we can come up with an > unobtrusive way to tell the docstring processing system to disregard > certain methods, it could be useful. Maybe a class attribute > equivalent of the "__all__" module attribute? Or perhaps the > opposite: a "__none__" class attribute ;). Well, there could be a directive in the docstring like: .. public: no Or I guess it would be more appropriate: :Public: no "Public" probably isn't the right term, but something like that. ":Obscure: yes" might be more correct ;) -- Ian Bicking Colorstudy Web Development ia...@co... http://www.colorstudy.com PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7 4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241 |
From: Beni C. <cb...@te...> - 2003-01-19 12:00:09
|
On 2003-01-18, David Goodger wrote: > I have begun work on a Python Source Reader component which will > accomplish this. > Forgot to announce it; since the source reader is not ready for use (is it?), I think somebody might benefit from my solution. I've written code that was documented with rST docstrings but couldn't use them (pydoc ignores the rST, docutils barfs at the python code). So I took the plain-text formatter of pydoc and hacked it until the result was a document with chapters instead of the "| " nesting, etc., so that it could be processed by the plain rST reader of docutils. It wasn't ideal, most notably interpretted text was just ignored instead of becoming references (that could be quick-fixed, I think, for 80% percent of the cases). In fact only references in the class hierarchy (converted to a nested list) were explicitly turned into links and classes were prepended with link targets. There were lots of empty lines and the text looked much less readable than the original pydoc's output. After processing with docutils this was hidden but the result didn't look much better (if at all) than pydoc's html. The most important benefit was that I was able to validate my docstrings with docutils for being correct rST (actually sometimes it was wrong because of the dumb conversion and I had to change my docs to work around). If somebody wants my code, I'll upload it later today. Please don't read it ;-), it was very quick and dirty - I just mutated the text formatter instead of copying as a new formatter, I changed it only until it worked on my docstrings so it could break on yours, etc. > Ian Bicking wrote: > > One thing I *don't* like is reference documentation in the style of > > pydoc.To me it's too automatic, and generally too hard to follow. > > I find reference documentation with some framework of text (lead-in > > paragraphs, categorization, etc) to be much better. > Like GNU info files tend to be? libc, elisp, make, they have the best hierarchically organised documentation that I've ever read. Puts everything in the right place in your head after first reading but also allows you to quickly read just what you need. I'm now writing a library that I'd like to document very well, and info files are my standard of excellence ;-). So I want to figure out a way for creating such documentation with docutils, too. Now that I think of it, is anyone else interested in a GNU info writer for docutils? If yes, I'll append it to my task queue (i.e. don't hold your breath). > That can be tricky.One idea I had (documented in the spec/notes > file) is to recognize JavaDoc-style documentation comments almost > anywhere in the code.This would allow a more "literate programming" > approach than what pydoc provides. > I'm not sure comments/strings in the code have anything to do with this. It's about writing extra overview/design documentation tat doesn't necessarily follow the code structure (and would be of higher quality if the programmer is not tempted to bind them together for saving a few lines of typing). > > My vision for a docstring-based reference documentation would > > probably look like: > > > > """ > > Module > > ====== > > > > This module does X, Y, Z.Most work will be done through the class: > > > > .. docstring:: MainClass > > > > In certain cases you may wish to access the functionality > > separately, yada yada yada, and may wish to use: > > > > .. docstring:: some_function > > .. docstring:: some_other_function > > """ > > > > class MainClass: > > """ > > Recursively we continue, now with methods: > > > > .. docstring:: MainClass.some_method > > """ > Hmm, consider Leo outlines - I've never used it but it seems to be able to do this kind of thing... > Ienvision something more along the lines of this:: > > """ > A general description of the highlights of the module, with > references (interpreted text) to the details. We don't need > a "Module" title because it will be derived automatically. > > This module does X, Y, Z. Most work will be done through the > `MainClass` class. > > In certain cases you may wish to access the functionality > separately, yada yada yada, and may wish to use `some_function` > or `some_other_function` > """ > > class MainClass: > """ > Description of this class, with references to specific > methods like `some_method`. We don't need to fully qualify > (no "MainClass." prefix) because "some_method" is in the > local namespace. > """ > This are closest to what I was doing. The module & class docstrings will contain overview information, perhaphs even in many chapters, that would link to relevant places in the low-level per-method documentation. The problem with this approach is that it relies too much on hyperlinks for a good order of reading. The great thing about GNU info files is that they are also organised in an order that is almost optimal for one-pass front-to-back reading. Ian Bicking's idea is better because it allows you to specify the order of the documentation entries differently from the order of the code. > ## > # My idea from JavaDoc is to allow document comments > # interspersed in the code in some way, which will > # interleave with the code objects and docstrings. > # These would include section titles, allowing a > # subdivision of methods by category. For example: > > ## > # Magic Methods > # ============= > > def __str__(self): > """String representation of this object (pseudo-XML).""" > ... > I think I see your idea. But in many some cases this is short of what's needed. Consider (invented example) an application where many classes contain special `gui_repr` methods that defines the user interface for this object. They are completely irrelevant to the algorithms described in other methods, so a good manual will probably separate the documentation of all GUI methods into a separate chapter discussing them all at once. So I think there should be (optional) ways to specify reordering / reorganisation of nodes. I'm not sure how to do it in a convenient yet flexible way. In the above gui case, for example, I would want to grab all these methods without listing each one and risking omission. Probably Python scripting to generate the reorganisation info would do the trick but would not be equally applicable to non-python-source uses of rST. Also, for big documentation, it would make sense to hold the user-only parts in separate files, leaving only what's relevant to the source's design in the source. The current include directive might solve this task too, if the reorganisation is applied later. See `(standards) GNU Manuals`__ for more thougths in this direction and `(findutils) Top`__ for an example of a good manual that doesn't follow the code and even describes several different programs together. __ http://www.delorie.com/gnu/docs/GNU/standards_28.html __ http://www.delorie.com/gnu/docs/findutils/find_toc.html -- Beni Cherniavsky <cb...@tx...> There is an Excel spreadsheet here. Do you want to open it? y There was a grid bug in the spreadsheet. The grid bug bites. |
From: Ian B. <ia...@co...> - 2003-01-20 09:19:34
|
On Sun, 2003-01-19 at 06:00, Beni Cherniavsky wrote: > Forgot to announce it; since the source reader is not ready for use (is > it?), It seems to work okay for me -- I think David might have some features he'd like, but what's there seems sufficient to me. > I think somebody might benefit from my solution. I've written code > that was documented with rST docstrings but couldn't use them (pydoc > ignores the rST, docutils barfs at the python code). So I took the > plain-text formatter of pydoc and hacked it until the result was a > document with chapters instead of the "| " nesting, etc., so that it could > be processed by the plain rST reader of docutils. Ack... sounds like a mess. > > Ian Bicking wrote: > > > One thing I *don't* like is reference documentation in the style of > > > pydoc.To me it's too automatic, and generally too hard to follow. > > > I find reference documentation with some framework of text (lead-in > > > paragraphs, categorization, etc) to be much better. > > > Like GNU info files tend to be? libc, elisp, make, they have the best > hierarchically organised documentation that I've ever read. Puts > everything in the right place in your head after first reading but also > allows you to quickly read just what you need. > > I'm now writing a library that I'd like to document very well, and info > files are my standard of excellence ;-). So I want to figure out a way > for creating such documentation with docutils, too. Documenting a library is different then a program, in my mind. Or at least there should be some entirely thorough but not necessarily intuitively structured documentation. In Webware I'm also making documents that are task and instruction oriented. But they don't make up for the reference documentation that you want when you're already familiar with the library, or at least the concept behind the library, and you just want to know how to spell the method name or something. This is how I use the Python reference documentation -- which on the whole is quite good -- and is how I'd expect to use a docstring extractor. I just write the other documents in a separate file. > Now that I think of it, is anyone else interested in a GNU info writer > for docutils? If yes, I'll append it to my task queue (i.e. don't hold > your breath). Info documents are often well organized, but the actual reader I've never been impressed with. I get lost too easily. But web pages certainly aren't ideal either. > > > > """ > > A general description of the highlights of the module, with > > references (interpreted text) to the details. We don't need > > a "Module" title because it will be derived automatically. > > > > This module does X, Y, Z. Most work will be done through the > > `MainClass` class. > > > > In certain cases you may wish to access the functionality > > separately, yada yada yada, and may wish to use `some_function` > > or `some_other_function` > > """ > > > > class MainClass: > > """ > > Description of this class, with references to specific > > methods like `some_method`. We don't need to fully qualify > > (no "MainClass." prefix) because "some_method" is in the > > local namespace. > > """ > > > This are closest to what I was doing. The module & class docstrings will > contain overview information, perhaphs even in many chapters, that would > link to relevant places in the low-level per-method documentation. > > The problem with this approach is that it relies too much on hyperlinks > for a good order of reading. The great thing about GNU info files is that > they are also organised in an order that is almost optimal for one-pass > front-to-back reading. Ian Bicking's idea is better because it allows you > to specify the order of the documentation entries differently from the > order of the code. I'm realizing that reordering the methods might be best anyway -- usually they don't match up with the description because they were just written in a certain order. The whole hyperlinking thing I'm still unsure about. I don't even know if there's a way to indicate that `references` should be turned into some sort of link. > > ## > > # My idea from JavaDoc is to allow document comments > > # interspersed in the code in some way, which will > > # interleave with the code objects and docstrings. > > # These would include section titles, allowing a > > # subdivision of methods by category. For example: > > > > ## > > # Magic Methods > > # ============= > > > > def __str__(self): > > """String representation of this object (pseudo-XML).""" > > ... > > > I think I see your idea. But in many some cases this is short of what's > needed. Consider (invented example) an application where many classes > contain special `gui_repr` methods that defines the user interface for > this object. They are completely irrelevant to the algorithms described > in other methods, so a good manual will probably separate the > documentation of all GUI methods into a separate chapter discussing them > all at once. When you start getting into that level or organization you have to have an application-wide view for the document. I'm just thinking of modules now -- but there certainly are many modules that aren't well contained. > So I think there should be (optional) ways to specify reordering / > reorganisation of nodes. I'm not sure how to do it in a convenient yet > flexible way. In the above gui case, for example, I would want to grab > all these methods without listing each one and risking omission. > Probably Python scripting to generate the reorganisation info would do the > trick but would not be equally applicable to non-python-source uses of > rST. I know... I've already thought of several packages I have that I'd like to autogenerate the documentation, but the format needs to be structured different from how it generally would be. For instance, in one library I have error strings that can be overridden -- these could be extracted, but only by a program that understood how my specific code was structured. > Also, for big documentation, it would make sense to hold the user-only > parts in separate files, leaving only what's relevant to the source's > design in the source. The current include directive might solve this task > too, if the reorganisation is applied later. I'm not sure what you mean here...? -- Ian Bicking Colorstudy Web Development ia...@co... http://www.colorstudy.com PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7 4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241 |