Skip to content

Commit

Permalink
html2myst: handle admonitions specially.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicah committed Aug 30, 2024
1 parent f8c9fde commit 5ebba41
Show file tree
Hide file tree
Showing 117 changed files with 18 additions and 1,672 deletions.
31 changes: 18 additions & 13 deletions html2myst/html2myst.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ def process_declaration(self, element):
else:
return nodes.Block(f'{{cpp:function}} {declaration}')

def process_admonition_block(self, container, element):
for child in element.children:
if has_class(child, 'title'):
continue
elif has_class(child, 'graphic'):
container += self.process_admonition_block(container, child)
elif child.name == 'div' and has_class(child, 'text'):
for grandchild in child.children:
container += self.process_block(grandchild)
elif child.name == 'img' and has_class(child, 'icon'):
continue
else:
print(fg.li_red, 'ADMONITION: UNKNOWN BLOCK')
print(child, reset)
continue

# not 100% sure on the return type...
def process_block(self, element):
if element.name == 'p':
Expand All @@ -204,19 +220,8 @@ def process_block(self, element):
kind = ''.join([cls for cls in element['class'] if cls != 'admonition'])

admonition = nodes.BlockContainer(f'{{admonition}} {title}\n:class: {kind}')
# what about other children?
for child in element.select(':scope p, :scope pre, :scope div'):
if child.name == 'div':
print(fg.li_yellow, 'Admonition with unknown div child, skipping:', reset)
print(child)
pass
block = self.process_block(child)
admonition += block
for child in element.children:
if child.name == 'p' or child.name == 'pre' or child.name == 'div':
pass
else:
print(fg.li_red, 'Unhandled admonition child type:', fg.li_yellow, child.name, reset)

self.process_admonition_block(admonition, element)
return admonition
if element.name == 'pre':
if has_class(element, 'cpp'):
Expand Down
6 changes: 0 additions & 6 deletions kits/application/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ line arguments are used in launching the application from the shell, or if

:::{admonition} Warning
:class: warning






This function isn't called if there were no command line arguments, or if
{cpp:func}`BRoster::Launch()` was called without
{hparam}`argv`/{hparam}`argc` values.
Expand Down
6 changes: 0 additions & 6 deletions kits/application/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ and {cpp:expr}`false` if the {hclass}`BClipboard` object was deleted while

:::{admonition} Warning
:class: warning






There's no way to tell {hmethod}`Lock()` to time out.
:::

Expand Down
12 changes: 0 additions & 12 deletions kits/application/handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ message source.

:::{admonition} Important
:class: important






Do not delete the argument message when you're done with. It doesn't belong
to you.
:::
Expand Down Expand Up @@ -500,12 +494,6 @@ to the observer, so both must be attached to a looper at the time

:::{admonition} Note
:class: note






The forms of {hmethod}`StartWatching()` and {hmethod}`StartWatchingAll()`
that accept a {hclass}`BHandler` can be used to observe a handler that's
not yet attached to a looper. However, these only work if the observer and
Expand Down
12 changes: 0 additions & 12 deletions kits/application/invoker.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ with no time limit on the reply.

::::{admonition} Note
:class: note






Regarding the use of the default message vs the argument, a common practice
is to reserve the default message as a template, and pass a fine-tuned copy
to {hmethod}`Invoke()`
Expand Down Expand Up @@ -326,12 +320,6 @@ widths: auto

:::{admonition} Warning
:class: warning






{hmethod}`SetTarget()` doesn't detect invalid {cpp:class}`BLooper`s and
{cpp:class}`BMessenger`s.
:::
Expand Down
18 changes: 0 additions & 18 deletions kits/application/looper.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ are destroyed by the {cpp:func}`~BLooper::Quit()` function.

::::{admonition} Warning
:class: warning






If you create a {hclass}`BLooper`-derived class that uses multiple
inheritance, make sure the first class your mixin class inherits from is
{hclass}`BLooper`; otherwise, you'll crash when you try to close the
Expand Down Expand Up @@ -237,12 +231,6 @@ can examine the list but you shouldn't modify or delete it.

:::{admonition} Warning
:class: warning






For all but {hmethod}`CommonFilterList()`, the {hclass}`BLooper` must be
locked.
:::
Expand Down Expand Up @@ -555,12 +543,6 @@ it unlocks the object before it returns. Keep in mind that a

:::{admonition} Caution
:class: caution






Calling {hmethod}`Run()` on a {hclass}`BLooper` that's already running will
dump you into the debugger.
:::
Expand Down
6 changes: 0 additions & 6 deletions kits/application/message.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,6 @@ only, item in the array.

:::{admonition} Important
:class: important






In all cases except {hmethod}`FindData()` and {hmethod}`FindString()`, the
data that's retrieved from the {hclass}`BMessage` is copied into the
reference argument; the caller is responsible for freeing the copied data.
Expand Down
24 changes: 0 additions & 24 deletions kits/application/messenger.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ still exists.

:::{admonition} Warning
:class: warning






This function doesn't tell you whether the looper is actually ready to
receive messages, or whether the handler (if it was specified in the
constructor) exists. In other words, a valid {hclass}`BMessenger` is no
Expand All @@ -136,12 +130,6 @@ guarantee that a message will actually get to the target.

:::{admonition} Important
:class: important






These functions apply to local targets only.
:::

Expand Down Expand Up @@ -189,12 +177,6 @@ The target can respond to the message:

- :::{admonition} Warning
:class: warning






Use caution when requesting a synchronous reply: If you call
{hmethod}`SendMessage()` from the target looper's thread, you'll deadlock
(or, at best, time out).
Expand Down Expand Up @@ -240,12 +222,6 @@ widths: auto

:::{admonition} Warning
:class: warning






If you specified a {hparam}`handler` when you constructed your
{hclass}`BMessenger`, and if that handler has since changed loopers,
{hmethod}`SendMessage()` won't deliver its message, but it doesn't complain
Expand Down
24 changes: 0 additions & 24 deletions kits/device/joystick.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ joystick and partly functions of the computer's hardware.

:::{admonition} Note
:class: note






Typically you won't use these data members if you're using enhanced mode;
they're provided primarily for backward compatibility.
:::
Expand Down Expand Up @@ -177,12 +171,6 @@ The names returned by {hmethod}`GetDeviceName()` can be passed into the

:::{admonition} Note
:class: note






The {hclass}`BJoystick` doesn't need to have an open device before you use
these functions; in fact, your application will typically use these to
provide user interface allowing the user to choose the joystick device
Expand Down Expand Up @@ -436,12 +424,6 @@ to enable calibration; otherwise, specify {cpp:expr}`false`.

:::{admonition} Note
:class: note






The Joysticks preference application lets the user calibrate the joystick.
Calibration is enabled by default.
:::
Expand Down Expand Up @@ -496,12 +478,6 @@ specify {cpp:expr}`false` if you don't want enhanced mode.

:::{admonition} Note
:class: note






Even in enhanced mode, the classic {hclass}`BJoystick` data members are
valid (for compatibility with older applications). However, they only give
you access to the first two axes and buttons of the joystick.
Expand Down
18 changes: 0 additions & 18 deletions kits/game/direct-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ leave everything else to the drawing thread.

:::{admonition} Note
:class: note






{hmethod}`DirectConnected()` should only return when it can guarantee to
the application server that the request specified by {hparam}`info` will be
strictly obeyed.
Expand All @@ -107,12 +101,6 @@ that interests you.

:::{admonition} Warning
:class: warning






If your {hmethod}`DirectConnected()` implementation doesn't handle a
request within three seconds, the Application Server will intentionally
crash your application under the assumption that it's deadlocked. Be sure
Expand Down Expand Up @@ -143,12 +131,6 @@ if you need one.

:::{admonition} Warning
:class: warning






The {hmethod}`GetClippingRegion()` function can only be called from the
{cpp:func}`~BDirectWindow::DirectConnected()` function; calling it from
outside {cpp:func}`~BDirectWindow::DirectConnected()` will return invalid
Expand Down
6 changes: 0 additions & 6 deletions kits/game/file-game-sound.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ used for playing the sound; {cpp:expr}`NULL` uses the default sound player.

:::{admonition} Note
:class: note






Currently, {hparam}`device` must always be {cpp:expr}`NULL`.
:::

Expand Down
6 changes: 0 additions & 6 deletions kits/game/push-game-sound.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ for playback.

:::{admonition} Note
:class: note






Currently, {hparam}`device` must always be {cpp:expr}`NULL` to indicate
that the default playback device should be used.
:::
Expand Down
6 changes: 0 additions & 6 deletions kits/game/simple-game-sound.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ used for playing the sound; {cpp:expr}`NULL` uses the default sound player.

:::{admonition} Note
:class: note






Currently, {hparam}`device` must always be {cpp:expr}`NULL`.
:::

Expand Down
6 changes: 0 additions & 6 deletions kits/game/streaming-game-sound.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ By default, two audio buffers are used.

:::{admonition} Note
:class: note






Currently, {hparam}`device` must always be {cpp:expr}`NULL` to indicate
that the default playback device should be used.
:::
Expand Down
12 changes: 0 additions & 12 deletions kits/game/window-screen.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ structure is defined in addons/graphics/GraphicsCard.h

:::{admonition} Note
:class: note






The information returned by this function is only valid when the
{hclass}`BWindowScreen` is connected to the display.
:::
Expand Down Expand Up @@ -229,12 +223,6 @@ defined in addons/graphics/GraphicsCard.h

:::{admonition} Note
:class: note






The information returned by this function is only valid if
{cpp:func}`~BWindowScreen::SetFrameBuffer()` has been called.
:::
Expand Down
Loading

0 comments on commit 5ebba41

Please sign in to comment.