Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hyperlinking and other HTML stuff #177

Closed
wants to merge 14 commits into from
Closed

Fix hyperlinking and other HTML stuff #177

wants to merge 14 commits into from

Conversation

kernc
Copy link
Contributor

@kernc kernc commented Sep 23, 2018

The commits seem disjoint, but really are just a series of patches that pretty much restores (and a bit builds upon) the previous HTML output behavior.

Please see commits individually.

Changes of note:

  • Markdown2 is back to Markdown1. Fenced code works. As does everything else. See the commit message.
  • Links in the sidebar and links in markdown now work.
  • Documenting only public submodules/members has been restored.
  • Pygments has been replaced with client-side highlighting with Highlight.js.
  • A couple other HTML template changes.

Of course, everything is open to discussion.

Kernc added 14 commits September 23, 2018 04:03
This reverts commit 6b0b0c3.

Compared to Python-Markdown, which is [maintained],
Markdown2 is [bug-ridden]. Incorrectly renders at least:

    [`code`](links)

which is important for us. The owner seems to [think it] an
edge case despite numerous such reports.

Python-Markdown has [12k dependents] whereas Markdown2 has
[only 1.3k], making the former's community quite a bit larger.

Finally, the [initial reason] for switch to Markdown2 was its
handling of fenced code blocks (with an addon). But
Python-Markdown supports this case just the same, with an addon.

[maintained]: https://github.com/Python-Markdown/markdown/issues
[bug-ridden]: https://github.com/trentm/python-markdown2/issues
[think it]: trentm/python-markdown2#259
[12k dependents]: https://libraries.io/pypi/Markdown/usage
[only 1.3k]: https://libraries.io/pypi/markdown2/usage
[initial reason]: #119
return _pdoc.get("%s.%s" % (self.name, name), False) is None

def exported(name):
exported = name == "__init__" or _is_exported(name)
return not forced_out(name) and exported
inheried = name not in self.cls.__dict__
Copy link
Contributor Author

@kernc kernc Sep 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now skips listing inherited members that have not been overridden. E.g.

class C:
   def f(self): pass
   def g(self): pass

class D(C):
   def g(self): pass
   def h(self): pass

Here for D, only g() and h() will be documented, while for C, f() and g().

The rationale is one can look into hyperlinked ancestors for the inherited members, less repetition etc.

Even though it looks quite pretty in the project I'm working with, I imagine not all projects would like/expect this. Can be made a setting if __pdoc__ "protocol" is extended. Please advise.

@@ -145,18 +147,20 @@ def lookup(module, refname, link_prefix):
return None, None
if isinstance(d, pdoc.doc.Module):
return d.refname, module_url(module, d, link_prefix)
suffix = '()' if isinstance(d, pdoc.doc.Function) else ''
name = d.qualname if get_qualname else d.name
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function references are by default labeled with their full qualified name, e.g. C.f or D.g in case of methods. Previously, it was the whole refname (module.submodule.submodule.whole.hierarchy.class.method). I think this is better, YMMV. Open to discussion.

Before when these helpers were part of the HTML template, it was much easier to override them (and specify --template-dir).

@kernc
Copy link
Contributor Author

kernc commented Sep 23, 2018

Happy to add tests once the premises are agreed upon.

Interestingly, current tests all pass when ran locally (edit: only in PyCharm).

@kernc
Copy link
Contributor Author

kernc commented Dec 8, 2018

Closed in favor of #182. Should anyone want to continue, welcome.

@kernc kernc closed this Dec 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant