@@ -82,7 +82,7 @@ def setup(app: Sphinx):
8282 [list , tuple ],
8383 )
8484 app .add_config_value ("tippy_add_class" , "" , "html" )
85- app .add_config_value ("tippy_skip_pages" , (), "html" ,(list , tuple ))
85+ app .add_config_value ("tippy_skip_pages" , (), "html" , (list , tuple ))
8686
8787 app .connect ("builder-inited" , compile_config )
8888 app .connect ("doctree-resolved" , collect_links_and_id_maps )
@@ -247,7 +247,9 @@ def merge_tippy_data(app: Sphinx, env, docnames: set[str], other: Any) -> None:
247247 env .tippy_data ["pages" ].update (other .tippy_data ["pages" ])
248248
249249
250- def collect_links_and_id_maps (app : Sphinx , doctree : nodes .document , docname : str ) -> None :
250+ def collect_links_and_id_maps (
251+ app : Sphinx , doctree : nodes .document , docname : str
252+ ) -> None :
251253 """Collect links and ID maps from the doctree during the environment reading phase."""
252254 if not doctree :
253255 # only process pages with a doctree,
@@ -270,8 +272,8 @@ def collect_links_and_id_maps(app: Sphinx, doctree: nodes.document, docname: str
270272 # Use standard doctree traversal to find all references (links)
271273 for node in doctree .traverse (nodes .reference ):
272274 # External URI check
273- if ' refuri' in node :
274- href = node [' refuri' ]
275+ if " refuri" in node :
276+ href = node [" refuri" ]
275277
276278 if href in tippy_config .custom_tips :
277279 custom_in_page .add (href )
@@ -306,13 +308,15 @@ def collect_links_and_id_maps(app: Sphinx, doctree: nodes.document, docname: str
306308 target = target or None
307309
308310 if path .endswith (".html" ):
309- other_docname = posixpath .normpath (posixpath .join (posixpath .dirname (docname ), path [:- 5 ]))
311+ other_docname = posixpath .normpath (
312+ posixpath .join (posixpath .dirname (docname ), path [:- 5 ])
313+ )
310314 if other_docname in app .env .all_docs :
311315 refs_in_page .add ((other_docname , target ))
312316
313317 # Internal Document ID check (local anchors)
314- elif ' refid' in node :
315- refs_in_page .add ((None , node [' refid' ]))
318+ elif " refid" in node :
319+ refs_in_page .add ((None , node [" refid" ]))
316320
317321 # create path based on pagename
318322 # we also add a unique ID to the path,
@@ -369,7 +373,7 @@ def create_element_id_map(doctree: nodes.document) -> dict[str, str]:
369373
370374
371375def create_id_to_tip_html (
372- config : TippyConfig , body : BeautifulSoup | Tag
376+ config : TippyConfig , body : BeautifulSoup | Tag
373377) -> dict [str | None , str ]:
374378 """Create a mapping of ids to the HTML to show in the tooltip."""
375379 id_to_html : dict [str | None , str ] = {}
@@ -388,6 +392,7 @@ def create_id_to_tip_html(
388392 def next_dd_after (node ):
389393 """Return the next <dd> after `node`, skipping intervening <dt> tags."""
390394 from bs4 import Tag
395+
391396 sib = node .next_sibling
392397 while sib :
393398 # Skip non-tags
@@ -503,11 +508,11 @@ def rewrite_local_attrs(content: str, rel_path: str) -> str:
503508
504509
505510def generate_page_js (
506- app : Sphinx ,
507- pagename : str ,
508- templatename : str ,
509- context : dict ,
510- doctree : nodes .document ,
511+ app : Sphinx ,
512+ pagename : str ,
513+ templatename : str ,
514+ context : dict ,
515+ doctree : nodes .document ,
511516) -> None :
512517 """Final step in page generation: parse HTML for tips and inject JS scripts."""
513518 if not doctree :
@@ -523,7 +528,9 @@ def generate_page_js(
523528 tippy_data = get_tippy_data (app )
524529
525530 if pagename not in tippy_data ["pages" ]:
526- LOGGER .warning (f"Tippy data not found for page: { pagename } . Skipping JS generation." )
531+ LOGGER .warning (
532+ f"Tippy data not found for page: { pagename } . Skipping JS generation."
533+ )
527534 return
528535
529536 page_data = tippy_data ["pages" ][pagename ]
@@ -532,7 +539,8 @@ def generate_page_js(
532539 for js_file in tippy_config .js_files :
533540 app .add_js_file (js_file , loading_method = "defer" )
534541 app .add_js_file (
535- str (page_data ["js_path" ].relative_to (Path (app .outdir , "_static" ))), loading_method = "defer"
542+ str (page_data ["js_path" ].relative_to (Path (app .outdir , "_static" ))),
543+ loading_method = "defer" ,
536544 )
537545
538546 if tippy_config .enable_mathjax :
@@ -709,7 +717,11 @@ def write_tippy_js(app: Sphinx, exception: Any):
709717 data ["id_to_html" ] = create_id_to_tip_html (tippy_config , content_div )
710718
711719 if not data ["id_to_html" ]:
712- LOGGER .warning (f"Could not extract local HTML tips from rendered file for: { pagename } . JS file will be empty." , type = "tippy" , subtype = "render" )
720+ LOGGER .warning (
721+ f"Could not extract local HTML tips from rendered file for: { pagename } . JS file will be empty." ,
722+ type = "tippy" ,
723+ subtype = "render" ,
724+ )
713725 continue
714726
715727 write_tippy_props_file (app , pagename , wiki_cache , doi_cache , rtd_cache )
@@ -756,11 +768,11 @@ def write_tippy_props_file(
756768 selector_to_html [f'a[href="{ relpage } .html"]' ] = rewrite_local_attrs (
757769 tippy_page_data [refpage ]["id_to_html" ][None ], relfolder
758770 )
759- elif (
760- target
761- and target in tippy_page_data [refpage ]["element_id_map" ]
762- ):
763- if tippy_page_data [ refpage ][ "element_id_map" ][ target ] not in tippy_page_data [ refpage ][ "id_to_html" ] :
771+ elif target and target in tippy_page_data [ refpage ][ "element_id_map" ]:
772+ if (
773+ tippy_page_data [refpage ]["element_id_map" ][ target ]
774+ not in tippy_page_data [ refpage ][ "id_to_html" ]
775+ ) :
764776
765777 html_path = Path (app .outdir ) / f"{ refpage } .html"
766778
@@ -770,11 +782,16 @@ def write_tippy_props_file(
770782
771783 body = BeautifulSoup (body_html , "lxml" )
772784 content_div = body .find ("div" , role = "main" ) or body
773- tippy_page_data [refpage ]["id_to_html" ] = create_id_to_tip_html (tippy_config , content_div )
785+ tippy_page_data [refpage ]["id_to_html" ] = (
786+ create_id_to_tip_html (tippy_config , content_div )
787+ )
774788
775789 if not tippy_page_data [refpage ]["id_to_html" ]:
776- LOGGER .warning (f"Could not extract local HTML tips from rendered file for: { refpage } ." ,
777- type = "tippy" , subtype = "render" )
790+ LOGGER .warning (
791+ f"Could not extract local HTML tips from rendered file for: { refpage } ." ,
792+ type = "tippy" ,
793+ subtype = "render" ,
794+ )
778795 continue
779796
780797 html_str = tippy_page_data [refpage ]["id_to_html" ][
@@ -806,7 +823,7 @@ def write_tippy_props_file(
806823 "{MathJax.typesetPromise([instance.popper]).then(() => {});},"
807824 )
808825 if tippy_config .enable_mathjax
809- and app .builder .math_renderer_name == "mathjax" # type: ignore[attr-defined]
826+ and app .builder .math_renderer_name == "mathjax" # type: ignore[attr-defined]
810827 else ""
811828 )
812829 # TODO need to only enable when math,
0 commit comments