Return the location of module docs or None
(self, object, basedir=sysconfig.get_path('stdlib'))
| 508 | docmodule = docclass = docroutine = docother = docproperty = docdata = fail |
| 509 | |
| 510 | def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')): |
| 511 | """Return the location of module docs or None""" |
| 512 | |
| 513 | try: |
| 514 | file = inspect.getabsfile(object) |
| 515 | except TypeError: |
| 516 | file = '(built-in)' |
| 517 | |
| 518 | docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS) |
| 519 | |
| 520 | basedir = os.path.normcase(basedir) |
| 521 | if (isinstance(object, type(os)) and |
| 522 | (object.__name__ in ('errno', 'exceptions', 'gc', 'imp', |
| 523 | 'marshal', 'posix', 'signal', 'sys', |
| 524 | '_thread', 'zipimport') or |
| 525 | (file.startswith(basedir) and |
| 526 | not file.startswith(os.path.join(basedir, 'site-packages')))) and |
| 527 | object.__name__ not in ('xml.etree', 'test.test_pydoc.pydoc_mod')): |
| 528 | if docloc.startswith(("http://", "https://")): |
| 529 | docloc = "{}/{}.html".format(docloc.rstrip("/"), object.__name__.lower()) |
| 530 | else: |
| 531 | docloc = os.path.join(docloc, object.__name__.lower() + ".html") |
| 532 | else: |
| 533 | docloc = None |
| 534 | return docloc |
| 535 | |
| 536 | # -------------------------------------------- HTML documentation generator |
| 537 |