Return the location of module docs or None
(self, object, basedir=sysconfig.get_path('stdlib'))
| 562 | docmodule = docclass = docroutine = docother = docproperty = docdata = fail |
| 563 | |
| 564 | def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')): |
| 565 | """Return the location of module docs or None""" |
| 566 | |
| 567 | try: |
| 568 | file = inspect.getabsfile(object) |
| 569 | except TypeError: |
| 570 | file = '(built-in)' |
| 571 | |
| 572 | docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS) |
| 573 | |
| 574 | basedir = os.path.normcase(basedir) |
| 575 | if (isinstance(object, type(os)) and |
| 576 | (object.__name__ in ('errno', 'exceptions', 'gc', |
| 577 | 'marshal', 'posix', 'signal', 'sys', |
| 578 | '_thread', 'zipimport') or |
| 579 | (file.startswith(basedir) and |
| 580 | not file.startswith(os.path.join(basedir, 'site-packages')))) and |
| 581 | object.__name__ not in ('xml.etree', 'test.test_pydoc.pydoc_mod')): |
| 582 | |
| 583 | try: |
| 584 | from pydoc_data import module_docs |
| 585 | except ImportError: |
| 586 | module_docs = None |
| 587 | |
| 588 | if module_docs and object.__name__ in module_docs.module_docs: |
| 589 | doc_name = module_docs.module_docs[object.__name__] |
| 590 | if docloc.startswith(("http://", "https://")): |
| 591 | docloc = "{}/{}".format(docloc.rstrip("/"), doc_name) |
| 592 | else: |
| 593 | docloc = os.path.join(docloc, doc_name) |
| 594 | else: |
| 595 | docloc = None |
| 596 | else: |
| 597 | docloc = None |
| 598 | return docloc |
| 599 | |
| 600 | # -------------------------------------------- HTML documentation generator |
| 601 |