Giter Site home page Giter Site logo

2024-slides's Introduction

2024-slides's People

Contributors

ftnext avatar

Stargazers

 avatar

Watchers

 avatar

2024-slides's Issues

継承まで使わずにNewTabLinkHTMLTranslator.starttagメソッドの代入で解決できないだろうか

class TweakedRevealjsSlideTranslator(
RevealjsSlideTranslator,
# To override starttag method to open link in new tab
NewTabLinkHTMLTranslator,
):

以下も試した

TweakedRevealjsSlideTranslator.starttag = NewTabLinkHTMLTranslator.starttag

make revealjsで落ちる

# Platform:         darwin; (macOS-12.6.6-arm64-arm-64bit)
# Sphinx version:   7.2.6
# Python version:   3.12.0 (CPython)
# Docutils version: 0.20.1
# Jinja2 version:   3.1.3
# Pygments version: 2.17.2

# Last messages:
#   copying assets...
#   copying static files...
#   done
#   copying extra files...
#   done
#   done
#   �[2K
#   writing output... [ 50%]
#   index
#   

# Loaded extensions:
#   sphinx.ext.mathjax (7.2.6)
#   alabaster (0.7.16)
#   sphinxcontrib.applehelp (1.0.8)
#   sphinxcontrib.devhelp (1.0.6)
#   sphinxcontrib.htmlhelp (2.0.5)
#   sphinxcontrib.serializinghtml (1.1.10)
#   sphinxcontrib.qthelp (1.0.7)
#   sphinx.ext.githubpages (7.2.6)
#   sphinx_revealjs._ext.highlightings (2.9.3)
#   sphinx_revealjs._ext.notes (2.9.3)
#   sphinx_revealjs (2.9.3)
#   sphinx_design (0.5.0)
#   custom_translator (unknown version)

# Traceback:
Traceback (most recent call last):
  File "/.../venv/lib/python3.12/site-packages/sphinx/cmd/build.py", line 298, in build_main
    app.build(args.force_all, args.filenames)
  File "/.../venv/lib/python3.12/site-packages/sphinx/application.py", line 355, in build
    self.builder.build_update()
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 363, in build
    self.write(docnames, list(updated_docnames), method)
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 571, in write
    self._write_serial(sorted(docnames))
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/__init__.py", line 580, in _write_serial
    self.write_doc_serialized(docname, doctree)
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 661, in write_doc_serialized
    title = self.render_partial(title_node)['title'] if title_node else ''
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../venv/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 431, in render_partial
    self._publisher.publish()
  File "/.../venv/lib/python3.12/site-packages/docutils/core.py", line 237, in publish
    output = self.writer.write(self.document, self.destination)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../venv/lib/python3.12/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/.../venv/lib/python3.12/site-packages/sphinx/writers/html.py", line 36, in translate
    self.document.walkabout(visitor)
  File "/.../venv/lib/python3.12/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../venv/lib/python3.12/site-packages/docutils/nodes.py", line 178, in walkabout
    visitor.dispatch_visit(self)
  File "/.../venv/lib/python3.12/site-packages/sphinx/util/docutils.py", line 582, in dispatch_visit
    method(node)
  File "/.../venv/lib/python3.12/site-packages/sphinx/writers/html5.py", line 473, in visit_title
    super().visit_title(node)
  File "/.../venv/lib/python3.12/site-packages/docutils/writers/_html_base.py", line 1669, in visit_title
    self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../venv/lib/python3.12/site-packages/sphinx_new_tab_link/__init__.py", line 21, in starttag
    return super().starttag(node, tagname, *args, **atts)
           ^^^^^^^^^^^^^^^^
TypeError: super(type, obj): obj must be an instance or subtype of type

superがうまくいっていない
https://docs.python.org/ja/3/library/functions.html#super

(Pdb) self
<custom_translator.TweakedRevealjsSlideTranslator object at 0x102d603b0>

starttagの代入であって、NewTabLinkHTMLTranslatorが親クラスに入っていないからではないか
ここではNewTabLinkHTMLTranslatorの親クラスのstarttagが上書きできればいいので、以下で動いた(ただしワークアラウンド)

-         return super().starttag(node, tagname, *args, **atts)
+         return super(self.__class__, self).starttag(node, tagname, *args, **atts)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.