Commit Graph

244 Commits

Author SHA1 Message Date
Brett Cannon 84601f14a3 Change pydoc.stripid() be able to match against 64-bit addresses by having
regex match from 6 to 16 characters.
2004-06-19 01:22:48 +00:00
Brett Cannon c6c1f478d9 pydoc.stripid() is now case-insensitive for its regex to support platforms that
have pointer addresses in uppercase.

Closes bug #934282.  Thanks Robin Becker.
2004-06-19 01:02:51 +00:00
Skip Montanaro a5616d2255 Respect a module's __all__ attribute. Closes #969938. 2004-06-11 04:46:12 +00:00
Skip Montanaro f2134842b4 correct name error caught by Neal Norwitz with pychecker 2004-06-07 02:40:05 +00:00
Raymond Hettinger 756b3f3c15 * Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
2004-01-29 06:37:52 +00:00
Martin v. Löwis f9b08b8e60 Patch #785689: Use basename in usage. Backported to 2.3. 2003-10-31 13:05:21 +00:00
Raymond Hettinger 6b59f5f3fd Let library modules use the new keyword arguments for list.sort(). 2003-10-16 05:53:16 +00:00
Skip Montanaro 4997a69fe4 display link to module docs when it looks like the object module is a core
module
2003-09-10 16:47:51 +00:00
Skip Montanaro 0fe8fce7e3 (HTML|Text)Repr.repr1: Guard against objects whos types have no __name__
attribute. Patch and bug report from Geoff Talvola. Closes patch #672855.
2003-06-27 15:45:41 +00:00
Martin v. Löwis b8c084e82c Support keyword and topics help in cli(). Fixes #715782. 2003-06-14 09:03:46 +00:00
Brett Cannon 28a4f0f965 Have pydoc try handling an object as "other" if the object does not act the way
it expects based on what inspect classifies it as.

Closes bug #729103 .
2003-06-11 23:38:55 +00:00
Neal Norwitz 54f871e193 Fix SF bug #735694, Pydoc.py fixes links
Modified the patch some.  Fixed invalid link in UNICODE (to STRING).
Also updates some references.
2003-05-26 13:49:54 +00:00
Martin v. Löwis e59e2bab8f Patch #711902: Cause pydoc to show data descriptor __doc__ strings. 2003-05-03 09:09:02 +00:00
Neal Norwitz 742dde4ddd SF patch #706338, Fix a few broken links in pydoc by Greg Chapman 2003-03-30 20:31:34 +00:00
Ka-Ping Yee d9e213eeca Hide private names beginning with _ (but don't hide __special__ names).
Clean up section headings; make the bars on the left less fat.
Adjust the display of properties slightly.
Don't show stuff inherited from the base 'object' type.
2003-03-28 16:35:51 +00:00
Neal Norwitz 4f959d2c73 Fix SF patch #695581, "returnself" -> "return self" 2003-03-01 15:22:41 +00:00
Guido van Rossum 68468eba63 Get rid of many apply() calls. 2003-02-27 20:14:51 +00:00
Guido van Rossum 97dede0202 Fix for SF 686380, from SF patch 686771 by Ping. (errors trying to
get help on os attributes)
2003-02-16 01:12:32 +00:00
Neal Norwitz f98159c376 Fix SF bug #642168, help() fails for some builtin topics
Fix pydoc when doing help for:  and, or, not, UNICODE.

Will backport.
2003-02-07 20:49:40 +00:00
Tim Peters 550e4e5583 SF bug 666444: 'help' makes linefeed only under Win32.
Reverting one of those irritating "security fixes".  fdopen() opens
files in binary mode.  That makes pydoc skip the \r\n on Windows that's
need to make the output readable in the shell.  Screw it.
2003-02-07 01:53:46 +00:00
Martin v. Löwis 5b26abb37a Gracefully delay runtime error up to 1s. Add .willdispatch(). 2002-12-28 09:23:09 +00:00
Raymond Hettinger 4f759d8504 Correct erroneous parenthesis placement in the delta from 1.63 to 1.64. 2002-11-02 02:02:46 +00:00
Tim Peters fb05c4e5bb SF bug 630824: pydoc Helper keywords missing 'yield'
Wow, what a brittle subsystem!  Fixed, maybe, provided Fred doesn't
shuffle the docs around.

Bugfix candidate.
2002-10-30 05:21:00 +00:00
Raymond Hettinger fca3bb6a29 Explicitly use floor division 2002-10-21 04:44:11 +00:00
Skip Montanaro d404bee2e2 try executing 'less' in a parenthesized subshell - prevents systems like
Solaris from squawking if less isn't available.  See
http://python.org/sf/612111 for details.
2002-09-26 21:44:57 +00:00
Jack Jansen b2628b0f37 Added the standard MacOSX location for documentation inside a framework
to the list of places where pydoc looks for HTML documents.
2002-08-23 08:40:42 +00:00
Ka-Ping Yee 45daeb093f Extend stripid() to handle strings ending in more than one '>'.
Add resolve() to handle looking up objects and names (fix SF bug 586931).
Add a nicer error message when given a filename that doesn't exist.
2002-08-11 15:11:33 +00:00
Guido van Rossum 3b0a3293c3 Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Weinberg).  This changes all uses of deprecated tempfile functions to
the recommended ones.
2002-08-09 16:38:32 +00:00
Guido van Rossum fce538c31e Add a coding cookie, because of the møøse quote. 2002-08-06 17:29:38 +00:00
Raymond Hettinger 32200aeac6 Replaced obsolete stat module constants with equivalent attributes 2002-06-01 19:51:15 +00:00
Raymond Hettinger 54f0222547 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:18:47 +00:00
Guido van Rossum 5e355b244f In both spilldata() functions, pretend that the docstring for
non-callable objects is always None.  This makes for less confusing
output and fixes the problem reported in SF patch #550290.
2002-05-21 20:56:15 +00:00
Guido van Rossum 8ca162f417 Partial introduction of bools where appropriate. 2002-04-07 06:36:23 +00:00
Tim Peters bc0e910826 Convert a pile of obvious "yes/no" functions to return bool. 2002-04-04 22:55:58 +00:00
Neil Schemenauer cddc1a0249 Quote href properly. 2002-03-24 23:11:21 +00:00
Neil Schemenauer d69711cb1e Remove unnecessary \b. It was causing the RE to miss the tailing
slash on strings like "http://www.python.org/ is good".
2002-03-24 23:02:07 +00:00
Skip Montanaro df708788b6 add repr_str as alias for repr_string in both HTMLRepr and TextRepr classes
- reflects the change in type("").__name__ between 2.1 and 2.2.  The
__name__ field is used to find a method to call for particular types.
2002-03-07 22:58:02 +00:00
Andrew MacIntyre 54e0eabc2d OS/2 more program behaves like Win32 more
(see patch #514490, by Stefan Schwarzer)
2002-03-03 03:12:30 +00:00
Tim Peters 59ed448bc6 SF patch #474485: pydoc generates some bad html, from Rich Salz. 2001-10-31 04:20:26 +00:00
Tim Peters 8dd7adeb34 SF bug [#472347] pydoc and properties.
The GUI-mode code to display properties blew up if the property functions
(get, set, etc) weren't simply methods (or functions).

"The problem" here is really that the generic document() method dispatches
to one of .doc{routine, class, module, other}(), but all of those require
a different(!) number of arguments.  Thus document isn't general-purpose
at all:  you have to know exactly what kind of thing is it you're going
to document first, in order to pass the correct number of arguments to
.document for it to pass on.  As an expedient hack, just tacked "*ignored"
on to the end of the formal argument lists for the .docXXX routines so
that .document's caller doesn't have to know in advance which path
.document is going to take.
2001-10-18 19:56:17 +00:00
Tim Peters 8ac8be5988 docroutine() (both instances): Docstrings for class methods weren't
getting displayed, due to a special case here whose purpose I didn't
understand.  So just disabled the doc suppression here.

Another special case here skips the docs when picking apart a method
and finding that the im_func is also in the class __dict__ under
the same name.  That one I understood.  It has a curious consequence,
though, wrt inherited properties:  a static class copies inherited stuff
into the inheriting class's dict, and that affects whether or not this
special case triggers.  The upshoot is that pydoc doesn't show the
function docstrings of getter/setter/deleter functions of inherited
properties in the property section when the class is static, but does
when the class is dynamic (bring up Lib/test/pydocfodder.py under
GUI pydoc to see this).
2001-09-27 04:08:16 +00:00
Tim Peters 351e362d89 List class attrs in MRO order of defining class instead of by alphabetic
order of defining class's name.
2001-09-27 03:29:51 +00:00
Tim Peters 3ffeae130b Removed no-longer-true comment about pydoc working under all versions of
Python since 1.5 (virtually everything I changed over the last week relies
on "modern" features, particularly nested scopes).
2001-09-26 22:39:22 +00:00
Tim Peters c86f6ca2b6 Display a class's method resolution order, if it's non-trivial. "Trivial"
here means it has no more than one base class to rummage through (in which
cases there's no potential confusion about resolution order).
2001-09-26 21:31:51 +00:00
Tim Peters f33532cfef + Display property functions in the same order they're specified to
property() (get, set, del; not set, get, del).

+ Change "Data defined/inherited in ..." header lines to
  "Data and non-method functions defined/inherited in ...".  Things like
  the value of __class__, and __new__, and class vrbls like the i in
      class C:
          i = int
  show up in this section too.  I don't think it's worth a separate
  section to distinguish them from non-callable attrs, and there's no
  obvious reliable way to distinguish callable from non-callable attrs
  anyway.
2001-09-25 06:30:51 +00:00
Tim Peters 2306d246e8 + Got rid of all instances of <small>. Under IE5, GUI-mode pydoc has
always been close to useless, because the <small>-ified docstrings
  were too small to read, even after cranking up my default font size
  just for pydoc.  Now it reads fine under my defaults (as does most
  of the web <0.5 wink>).  If it's thought important to play tricks
  with font size, tough, then someone should rework pydoc to use style
  sheets, and (more) predictable percentage-of-default size controls.

+ Tried to ensure that all <dt> and <dd> tags are closed.  I've read (but
  don't know) that some browsers get confused if they're not, and esp.
  when style sheets are in use too.
2001-09-25 03:18:32 +00:00
Tim Peters 3e767d19e0 GUI mode now displays useful stuff for properties. This is usually better
than text mode, since here we can hyperlink from the getter etc methods
back to their definitions.
2001-09-25 00:01:06 +00:00
Tim Peters f4aad8eb28 + Text-mode (but not yet GUI mode) pydoc now produces useful stuff for
properties:  the docstring (if any) is displayed, and the getter, setter
  and deleter (if any) functions are named.  All that is shown indented
  after the property name.

+ Text-mode pydoc class display now draws a horizontal line between
  class attribute groups (similar to GUI mode -- while visually more
  intrusive in text mode, it's still an improvement).
2001-09-24 22:40:47 +00:00
Tim Peters fa26f7cc39 More work on class display:
+ Minor code cleanup, generalization and simplification.

+ "Do something" to make the attribute aggregation more apparent:
    - In text mode, stick a "* " at the front of subgroup header lines.
    - In GUI mode, display a horizontal rule between subgroups.
   For GUI mode, this is a huge improvement, at least under IE.
2001-09-24 08:05:11 +00:00
Tim Peters b47879b239 Try to do for pydoc's GUI mode what the earlier checkin did for text
mode (identify the source class for class attrs; segregate attrs according
to source class, and whether class method, static method, property, plain
method, or data; display data attrs; display docstrings for data attrs
when possible).

Alas, this is mondo ugly, and I'm no HTML guy.  Part of the problem is
that pydoc's GUI mode has always been ugly under IE, largely because
<small> under IE renders docstrings unreadably small (while sometimes
non-docstring text is painfully large).  Another part is that these
segregated listings of attrs would *probably* look much better as bulleted
lists.  Alas, when I tried that, the bullets all ended up on lines by
themselves, before the method names; this is apparently because pydoc
(ab?)uses definition lists for format effects, and at least under IE
if a definition list is the first chunk of a list item, it gets rendered
on a line after the <li> bullet.

An HTML wizard would certainly be welcomed here.
2001-09-24 04:47:19 +00:00
Tim Peters 28355496c1 Part of a partial solution to SF bugs 463378, 463381, 463383, 463384.
This almost entirely replaces how pydoc pumps out class docs, but only
in text mode (like help(whatever) from a Python shell), not in GUI mode.

A class C's attrs are now grouped by the class in which they're defined,
attrs defined by C first, then inherited attrs grouped by alphabetic order
of the defining classes' names.

Within each of those groups, the attrs are subgrouped according to whether
they're plain methods, class methods, static methods, properties, or data.
Note that pydoc never dumped class data attrs before.  If a class data
attr is implemented via a data descriptor, the data docstring (if any)
is also displayed (e.g., file.softspace).

Within a subgroup, the attrs are listed alphabetically.

This is a friggin' mess, and there are bound to be glitches.  Please
beat on it and complain!  Here are three glitches:

1. __new__ gets classifed as 'data', for some reason.  This will
   have to get fixed in inspect.py, but since the latter is already
   looking for any clue that something is a method, pydoc will
   almost certainly not know what to do with it when its classification
   changes.

2. properties are special-cased to death.  Unlike any other kind of
   function or method, they don't have a __name__ attr, so none of
   pydoc's usual code can deal with them.  Worse, the getter and
   setter and del'er methods associated with a property don't appear
   to be discoverable from Python, so there's really nothing I can
   think of to do here beyond just listing their names.

   Note that a property can't be given a docstring, either (or at least
   I've been unable to sneak one in) -- perhaps the property()
   constructor could take an optional doc argument?

3. In a nested-scopes world, pydoc still doesn't know anything about
   nesting, so e.g. classes nested in functions are effectively invisible.
2001-09-23 21:29:55 +00:00
Tim Peters 4bcfa317ee Since inspect.isfunction(obj) is a precondition for calling
inspect.getargspec(obj), test isfunction() directly in pydoc.py instead
of trying to indirectly deduce isfunction() in pydoc by virtue of
failing a combination of other tests.  This shouldn't have any visible
effect, except perhaps to squash a TypeError death if there was some path
thru this code that was inferring isfunction() by mistake.
2001-09-20 06:08:24 +00:00
Tim Peters 536d2262f7 After much thrashing, I believe this is a truly minimal patch to teach
pydoc how to do something sensible with 2.2 descriptors.  To see the
difference, browse __builtin__ via pydoc before and after the patch.
2001-09-20 05:13:38 +00:00
Fred Drake 5e9eb98ff6 Oh, ok, so plainpager is probably marginally better. 2001-07-23 19:48:10 +00:00
Fred Drake 0a66fcb116 If $TERM is "dumb" or "emacs", just dump the text instead of trying to run
"less".
Patch contributed by Alex Convertry.
This closes SF patch #443551.
2001-07-23 19:44:30 +00:00
Fred Drake e61967f537 Change some text just a little to avoid font-lock hell. 2001-05-10 18:41:02 +00:00
Ka-Ping Yee d03f8fe95e One-character style change to appease Netscape stylesheets. 2001-04-13 15:04:32 +00:00
Ka-Ping Yee 6191a23537 Use nturl2path to generate a file: URL to source files in Windows. 2001-04-13 15:00:27 +00:00
Ka-Ping Yee 9bc576b7f6 Use inspect.stack()[1][3] to tell if Helper.__repr__ is called interactively. 2001-04-13 13:57:31 +00:00
Ka-Ping Yee eca15c1fb1 Add inode checks to detect circular symbolic links (so that the
Tools/idle/idlelib link doesn't cause an infinite loop -- aack!)
2001-04-13 13:53:07 +00:00
Ka-Ping Yee 59685c5193 Small style change to accommodate Netscape. 2001-04-13 12:11:19 +00:00
Ka-Ping Yee da79389f10 Word-wrap the list of cross-references. 2001-04-13 11:02:51 +00:00
Ka-Ping Yee 79c009d767 Another pass through the topic table to fill in cross references.
Restore Helper.__repr__ for now.
2001-04-13 10:53:25 +00:00
Ka-Ping Yee dec96e92ae Make force-loading optional; don't force-load in interactive mode.
Make synopsis() load modules as '__temp__' so they don't clobber anything.
Change "constants" section to "data" section.
Don't show __builtins__ or __doc__ in "data" section.
For Bob Weiner: don't boldface text in Emacs shells or dumb terminals.
Remove Helper.__repr__ (it really belongs in site.py, and should be                 guarded by a check for len(inspect.stack) <= 2).
2001-04-13 09:55:49 +00:00
Ka-Ping Yee b7a48300cd Fix linking to classes (in class tree, and add links on unbound methods). 2001-04-12 20:39:14 +00:00
Ka-Ping Yee 6dcfa3884d Fix call to ModuleScanner from GUI search interface.
Fix handling of unbound top-level methods.
2001-04-12 20:27:31 +00:00
Ka-Ping Yee 35cf0a3f90 Added a big new Helper class to provide interactive help! 2001-04-12 19:53:52 +00:00
Ka-Ping Yee 131216290b Give up trying to keep dynamically loaded extensions up to date:
the import.c machinery has soundly defeated my every attempt.
2001-04-12 13:37:39 +00:00
Ka-Ping Yee fd540695e7 Remove forking. Doesn't work in Windows. 2001-04-12 12:54:36 +00:00
Ka-Ping Yee 662469619a Typo fixes and small touches. 2001-04-12 11:59:50 +00:00
Ka-Ping Yee 9aa0d90947 Properly qualify methods inherited from classes in other modules.
Fix so that docother() doesn't blow up.
Eliminate man() function since doc() and man() did nearly the same thing.
Various other code cleanup and refactoring to reduce duplication.
Simplify and rewrite freshimport() so modules are always up to date,
    even within packages (where reload() doesn't work).
Add finalization callback to the server (so that if the server fails to
    start for some reason, the main thread isn't left hanging).
2001-04-12 10:50:23 +00:00
Ka-Ping Yee 41763b9603 Fix typo in instantiation of ErrorDuringImport. 2001-04-10 12:22:01 +00:00
Ka-Ping Yee 5a804edd3c Fix synopsis() so it can handle binary module files.
Avoid ever using popen on Windows, since it's broken there.
Factor out the business of getting the summary line into splitdoc().
Use the modulename() routine in inspect.
Show all members of modules and classes rather than filtering on leading '_'.
Small typo and formtating fixes.
Don't show warnings when running "pydoc -k".
2001-04-10 11:46:02 +00:00
Ka-Ping Yee f78a81b47b Fix some reloading problems (still more work needed).
Add hyperlinks to PEPs at http://www.python.org/peps/pep-%04d.html
Remove script directory (dirname of sys.argv[0]) from sys.path.
2001-03-27 08:13:42 +00:00
Ka-Ping Yee e280c06d59 Browser compatibility fixes.
Show methods aliased into a class from other classes.
2001-03-23 14:05:53 +00:00
Ka-Ping Yee 987ec903d6 Small formatting improvements. 2001-03-23 13:35:45 +00:00
Ka-Ping Yee 3bda87991a Show inherited methods, with hyperlinks to the base class they came from.
Font adjustment to improve viewing in Windows (the default monospaced font,
    Courier New, seems to have no reasonable size in IE!)
Improve error handling.  Try very hard to distinguish between failure to
    find a module and failure during the module importing process.
Improve reloading behaviour.  (Still needs some work.)
Add '.' to sys.path when running as a script at the command-line.
Don't automatically assume '-g' based on the platform.  We'll just have
    the batch file supply -g.
2001-03-23 13:17:50 +00:00
Ka-Ping Yee 37f7b38eb6 Fixes for various issues reported and discovered since Python 9:
Factor description of import errors into DocImportError.__str__.
Add "docother" and "fail" methods to Doc class.
Factor formatting of constants into "docother".
Increase max string repr limit to 100 characters.
Factor page generation into HTMLDoc.page.
Handle aliasing of names (objects appearing under an attribute
    name different from their intrinsic __name__) by passing the
    attribute name into each doc* method.
Handle methods at top level of modules (e.g. in random).
Try to do reloading efficiently.

Important fixes still to do:
    Module reloading is broken by the unfortunate property that
        failed imports leave an incomplete module in sys.  Still
        need to think of a good solution.
    Can't document modules in the current directory, due to the
        other unfortunate property that sys.path gets '.' when
        you run 'python' but it gets the script directory when
        you run a script.  Need to ponder to find a solution.
    The synopsis() routine does not work on .so modules.
    Aliases cause duplicate copies of documentation to appear.
        This is easy to fix, just more work.
    Classes appear as their intrinsic name, not their attribute name,
        in the class hierarchy.  This should be fixed.
    Inherited methods should be listed in class descriptions.
2001-03-23 00:12:53 +00:00
Tim Peters 30edd2387d Whitespace normalization. 2001-03-16 08:29:48 +00:00
Ka-Ping Yee db8ed1517f Use '127.0.0.1' only on Mac; for other, sane platforms, use 'localhost'. 2001-03-02 05:58:17 +00:00
Ka-Ping Yee c92cdf7aa7 The sys.platform identifier for Windows is just 'win32' (for all varieties). 2001-03-02 05:54:35 +00:00
Guido van Rossum b616e114f7 Believe it or not, but "more" on Windows requires "more <file" rather
than "more file".  Since tempfilepager() is only used on Windows, it
seems, do this unconditionally -- on Unix, it always invokes something
else.
2001-03-02 04:27:08 +00:00
Ka-Ping Yee 239432a545 Clean up the handling of getsourcefile/getabsfile.
Remove __main__ from the index of built-in modules.
Miscellaneous compatibility fixes.
2001-03-02 02:45:08 +00:00
Ka-Ping Yee a2fe103c9b Use imp.get_suffixes to determine a module name in modulename(file).
When possible, display strings containing backslashes using r'' notation.
2001-03-02 01:19:14 +00:00
Ka-Ping Yee d977e35dd0 Also accept .so as an extension for module files. 2001-03-01 19:31:25 +00:00
Ka-Ping Yee 66efbc7481 Docstring improvements.
Add checks for .pyo and .pyd.
Collapse docfunction, docmethod, docbuiltin into the one method docroutine.
Small formatting fixes.
Link the segments of a package path in the title.
Link to the source file only if it exists.
Allow modules (e.g. repr.py) to take precedence over built-ins (e.g. repr()).
Add interruptible synopsis scanner (so we can do searches in the background).
Make HTTP server quit.
Add small GUI for controlling the server and launching searches (like -k).
    (Tested on Win2k, Win98, and Linux.)
2001-03-01 13:55:20 +00:00
Ka-Ping Yee 1d384634bf Normalize case of paths in sys.path to avoid duplicates on Windows.
Handle <... at 001B6378> like <... at 0x120f80> (%p is platform-dependent).
Fix RCS version tag handling.
Move __main__ behaviour into a function, pydoc.cli().
2001-03-01 00:24:32 +00:00
Tim Peters 85ba673b0a Whitespace normalization. 2001-02-28 08:26:44 +00:00
Ka-Ping Yee 457aab237f Macintosh compatibility. 2001-02-27 23:36:29 +00:00
Ka-Ping Yee 5e2b173333 Acknowledgements. 2001-02-27 23:35:09 +00:00
Ka-Ping Yee 40c49919fb Fix $Revision$ processing so it doesn't get eaten by CVS! 2001-02-27 22:46:01 +00:00
Ka-Ping Yee 09d7d9a552 Add $Revision: $ tag. 2001-02-27 22:43:48 +00:00
Ka-Ping Yee 6f3f9a4c64 Add display of $Revision $ and credits. 2001-02-27 22:42:36 +00:00
Ka-Ping Yee dd1753434a pydoc: text and HTML documentation generator for interactive use 2001-02-27 14:43:46 +00:00