Code documentation tool similar to what Ruby (on Rails?) uses

Discussion in 'Python' started by Ksenia Marasanova, Jun 12, 2005.

  1. Hi,

    I wonder if there is a tool for generation Python API documentation
    that can include source code into HTML output. Example:
    http://api.rubyonrails.com/ I really like the possibility to click on
    "show source" link and read the source of the method!

    AFAIK it is not possible with Epydoc and Pydoc.. but maybe other tools?

    Thanks!
    --
    Ksenia
     
    Ksenia Marasanova, Jun 12, 2005
    #1
    1. Advertising

  2. What about doing it yourself?

    >>> import inspect, os
    >>> print "<pre>%s</pre>" % inspect.getsource(os.makedirs)

    <pre>def makedirs(name, mode=0777):
    """makedirs(path [, mode=0777])

    Super-mkdir; create a leaf directory and all intermediate ones.
    Works like mkdir, except that any intermediate path segment (not
    just the rightmost) will be created if it does not exist. This is
    recursive.

    """
    head, tail = path.split(name)
    if not tail:
    head, tail = path.split(head)
    if head and tail and not path.exists(head):
    makedirs(head, mode)
    if tail == curdir: # xxx/newdir/. exists if
    xxx/newdir exists
    return
    mkdir(name, mode)
    </pre>

    Michele Simionato
     
    Michele Simionato, Jun 12, 2005
    #2
    1. Advertising

  3. 12 Jun 2005 08:12:14 -0700, Michele Simionato <>:
    > What about doing it yourself?
    >
    > >>> import inspect, os
    > >>> print "<pre>%s</pre>" % inspect.getsource(os.makedirs)


    That's easy, thanks! I guess I'll submit a patch for Epydoc with the
    functionality I've mentioned :)


    --
    Ksenia
     
    Ksenia Marasanova, Jun 12, 2005
    #3
  4. Ksenia Marasanova

    Andrew Dalke Guest

    Ksenia Marasanova responsded to Michele Simionato
    >> >>> print "<pre>%s</pre>" % inspect.getsource(os.makedirs)

    >
    > That's easy, thanks! I guess I'll submit a patch for Epydoc with the
    > functionality I've mentioned :)


    Before doing that, add a "cgi.escape()" to the text. Otherwise
    embedded [<>&] characters will be interpreted as HTML.

    Andrew
     
    Andrew Dalke, Jun 12, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sridhar R
    Replies:
    1
    Views:
    511
    Fredrik Lundh
    Apr 16, 2004
  2. hrishy
    Replies:
    0
    Views:
    290
    hrishy
    Oct 7, 2009
  3. Replies:
    6
    Views:
    201
    Michael Campbell
    Mar 17, 2005
  4. Josef 'Jupp' SCHUGT
    Replies:
    5
    Views:
    214
    Stephan Kämper
    Jan 24, 2006
  5. Jason Wong
    Replies:
    0
    Views:
    186
    Jason Wong
    Nov 20, 2007
Loading...

Share This Page