All, I've written a Sphinx extension which takes source code and transforms it to reST. Comments must be in reST, source code is left alone. The code still needs lots of tweaking, however. http://www.ece.msstate.edu/courses/ece3724/old/solutions/contents.html shows an example of the output run on a .c and a .s (assembly) file.
Bryan On Wed, Mar 7, 2012 at 1:12 PM, nicky van foreest <vanfore...@gmail.com>wrote: > Hi Victor, > > Thanks for your answer. Indeed, your proposal is better. But as you > also point out, it does not help solve my problem. > > I use xemacs, but not yet with the restructuredtext mode. I actually > write my code in a format that Pweave can read, and then let Pweave > make the rst file and run the code. Hence, rst-mode in xemacs is not > that useful, at least as it seems to me right now. > > I'll send my question to the restructuredtext mailing list. Perhaps > there somebody knows. > > Nicky > > On 7 March 2012 15:21, Viktor Haag <viktor.h...@desire2learn.com> wrote: > > I have tried both forms of introducing code, and fairly quickly settled > on > > using not the method you do, but this one: > > > > This function requires some explanation: > > > > > > .. code-block:: python > > > > > > def alsoHard(self): > > > > print "Success" > > > > > > As you can see, this function requires careful handling. > > > > > > I found that maintaining my docs over even just the few weeks I took > making > > this decision, the explicit "code-block" form had several advantages I > > wanted: > > > > - It was easier to notice problems from the output and quickly tie them > to > > problems in the docs (finding that trailing double-colon proved in some > > cases to be "invisible"). > > - It was easier for me to easily represent various kinds of code examples > > (which, admittedly, my docs needs, but yours might not) > > - It helped me visually account for where every block needed to be > indented > > as I worked > > - It explicitly reminded me what the language was for the code example > > > > Your mileage may vary, and I realize it doesn't directly address your > issue. > > > > In Emacs, there are functions in the restructured text editing mode to > block > > indent and outdent a region of text, which has proved useful. Of course, > > that only helps you out if you're using Emacs... > > > > -- > > V. > > > > > > > > > > On Tuesday, 6 March 2012 14:15:36 UTC-5, nicky wrote: > >> > >> Hi, > >> > >> I just joined this group. Thanks for making sphinx available. It makes > >> it very easy to make my code available on the web. > >> > >> I have a question about keeping indentation in an entire code block. I > >> would like to add documentation in between class methods, like so: > >> > >> > >> introduction > >> ================== > >> > >> :: > >> > >> class LongClass(): > >> def hardFunction(self): > >> return 3 > >> > >> This function requires substantial explanation > >> > >> :: > >> > >> def alsoHard(self): > >> print "success" > >> > >> > >> More explanations requiring mathematics. > >> > >> :: > >> > >> def simple(self): > >> print "aha" > >> > >> End of rst file > >> ---------------------- > >> > >> > >> The problem is that in the html file the methods are not indented > >> anymore, see > http://nicky.vanforeest.com/mg1StateProbabilities/hank.html. > >> Now, due to the removed indentation, the methods seem to have become > >> functions. Is there any way to repair this in the rst file? > >> > >> Thanks > >> > >> Nicky > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sphinx-dev" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/sphinx-dev/-/bhk6OBrDLUQJ. > > To post to this group, send email to sphinx-dev@googlegroups.com. > > To unsubscribe from this group, send email to > > sphinx-dev+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/sphinx-dev?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "sphinx-dev" group. > To post to this group, send email to sphinx-dev@googlegroups.com. > To unsubscribe from this group, send email to > sphinx-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sphinx-dev?hl=en. > > -- Bryan A. Jones, Ph.D. Associate Professor Department of Electrical and Computer Engineering 231 Simrall / PO Box 9571 Mississippi State University Mississippi state, MS 39762 http://www.ece.msstate.edu/~bjones bjones AT ece DOT msstate DOT edu voice 662-325-3149 fax 662-325-2298 Our Master, Jesus Christ, is on his way. He'll show up right on time, his arrival guaranteed by the Blessed and Undisputed Ruler, High King, High God. - 1 Tim. 6:14b-15 (The Message) -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-dev@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.