Skip to content

Commit

Permalink
fix 'on this page' section links and make button pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryduev committed Jul 25, 2023
1 parent 9cca95c commit 97728b1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dirname=python
title=Python Library
slug=wandb.
elements=Artifact,agent,config,controller,finish,init,log,save,summary,sweep,watch,__version__
;elements=log
;elements=Run
add-from=wandb_sdk.wandb_run
add-elements=Run
module-doc-from=self
Expand Down
2 changes: 1 addition & 1 deletion docugen/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def extract(
private_map: A {'path':["name"]} dictionary listing particular object
locations that should be ignored in the doc generator.
visitor_cls: A class, typically a subclass of
`doc_generator_visitor.DocGeneratorVisitor` that acumulates the indexes of
`doc_generator_visitor.DocGeneratorVisitor` that accumulates the indexes of
objects to document.
callbacks: Additional callbacks passed to `traverse`. Executed between the
`PublicApiFilter` and the accumulator (`DocGeneratorVisitor`). The
Expand Down
32 changes: 25 additions & 7 deletions docugen/pretty_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,12 @@ def _build_method_section(method_info, heading_level=3):
A markdown string.
"""
parts = []
heading = (
'<h{heading_level} id="{short_name}">'
"<code>{short_name}</code>"
"</h{heading_level}>\n\n"
)
# heading = (
# '<h{heading_level} id="{short_name}">'
# "<code>{short_name}</code>"
# "</h{heading_level}>\n\n"
# )
heading = "#" * heading_level + " `{short_name}`\n\n"
parts.append(heading.format(heading_level=heading_level, **method_info._asdict()))

if method_info.defined_in:
Expand Down Expand Up @@ -545,9 +546,26 @@ def _build_signature(
{table_footer}"""
)

# _TABLE_LINK_TEMPLATE = (
# "[![](https://www.tensorflow.org/images/GitHub-Mark-32px.png)"
# " View source on GitHub]({url})"
# )

_TABLE_LINK_TEMPLATE = (
"[![](https://www.tensorflow.org/images/GitHub-Mark-32px.png)"
"View source on GitHub]({url})"
"<p>"
"<button style={{{{display: 'flex', alignItems: 'center', "
"backgroundColor: 'white', border: '1px solid #ddd', padding: '10px', "
"borderRadius: '6px', cursor: 'pointer', "
"boxShadow: '0 2px 3px rgba(0,0,0,0.1)', transition: 'all 0.3s'}}}}>"
"<a href='{url}' style={{{{fontSize: '1.2em', "
"display: 'flex', alignItems: 'center'}}}}>"
"<img "
"src='https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png'"
" height='32px' width='32px' style={{{{marginRight: '10px'}}}}/>"
"View source on GitHub"
"</a>"
"</button>"
"</p>"
)


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r docugen/requirements.txt

dataclasses
markdownify
mistune

# for integrations
tensorflow

0 comments on commit 97728b1

Please sign in to comment.