diff --git a/docs/build/.buildinfo b/docs/build/.buildinfo index 42f6b2a7..35773b36 100644 --- a/docs/build/.buildinfo +++ b/docs/build/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 7f2341602339f5787e05519e6e1924b2 +config: 32dd555d207fe9d43466c601a4446270 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/.doctrees/disjunction_elimination.doctree b/docs/build/.doctrees/disjunction_elimination.doctree new file mode 100644 index 00000000..ba5d154e Binary files /dev/null and b/docs/build/.doctrees/disjunction_elimination.doctree differ diff --git a/docs/build/.doctrees/elimination_rule.doctree b/docs/build/.doctrees/elimination_rule.doctree index 6a4435e7..a7d0f34c 100644 Binary files a/docs/build/.doctrees/elimination_rule.doctree and b/docs/build/.doctrees/elimination_rule.doctree differ diff --git a/docs/build/.doctrees/environment.pickle b/docs/build/.doctrees/environment.pickle index 601fbeb4..731d2c7d 100644 Binary files a/docs/build/.doctrees/environment.pickle and b/docs/build/.doctrees/environment.pickle differ diff --git a/docs/build/.doctrees/formula_statement.doctree b/docs/build/.doctrees/formula_statement.doctree new file mode 100644 index 00000000..f8438505 Binary files /dev/null and b/docs/build/.doctrees/formula_statement.doctree differ diff --git a/docs/build/.doctrees/hypothesis.doctree b/docs/build/.doctrees/hypothesis.doctree new file mode 100644 index 00000000..93a56d10 Binary files /dev/null and b/docs/build/.doctrees/hypothesis.doctree differ diff --git a/docs/build/.doctrees/inconsistency_introduction_1.doctree b/docs/build/.doctrees/inconsistency_introduction_1.doctree new file mode 100644 index 00000000..847c7eab Binary files /dev/null and b/docs/build/.doctrees/inconsistency_introduction_1.doctree differ diff --git a/docs/build/.doctrees/inconsistency_introduction_2.doctree b/docs/build/.doctrees/inconsistency_introduction_2.doctree new file mode 100644 index 00000000..214c2a80 Binary files /dev/null and b/docs/build/.doctrees/inconsistency_introduction_2.doctree differ diff --git a/docs/build/.doctrees/inconsistency_introduction_3.doctree b/docs/build/.doctrees/inconsistency_introduction_3.doctree new file mode 100644 index 00000000..5ea66b55 Binary files /dev/null and b/docs/build/.doctrees/inconsistency_introduction_3.doctree differ diff --git a/docs/build/.doctrees/index.doctree b/docs/build/.doctrees/index.doctree index 1f50068f..70229efd 100644 Binary files a/docs/build/.doctrees/index.doctree and b/docs/build/.doctrees/index.doctree differ diff --git a/docs/build/.doctrees/introduction_rule.doctree b/docs/build/.doctrees/introduction_rule.doctree index 80bb1cfa..81c0f75f 100644 Binary files a/docs/build/.doctrees/introduction_rule.doctree and b/docs/build/.doctrees/introduction_rule.doctree differ diff --git a/docs/build/.doctrees/proof_by_contradiction_1.doctree b/docs/build/.doctrees/proof_by_contradiction_1.doctree new file mode 100644 index 00000000..2b658b07 Binary files /dev/null and b/docs/build/.doctrees/proof_by_contradiction_1.doctree differ diff --git a/docs/build/.doctrees/proof_by_contradiction_2.doctree b/docs/build/.doctrees/proof_by_contradiction_2.doctree new file mode 100644 index 00000000..a4c0dc1c Binary files /dev/null and b/docs/build/.doctrees/proof_by_contradiction_2.doctree differ diff --git a/docs/build/.doctrees/proof_by_refutation_1.doctree b/docs/build/.doctrees/proof_by_refutation_1.doctree new file mode 100644 index 00000000..9260ec3f Binary files /dev/null and b/docs/build/.doctrees/proof_by_refutation_1.doctree differ diff --git a/docs/build/.doctrees/proof_by_refutation_2.doctree b/docs/build/.doctrees/proof_by_refutation_2.doctree new file mode 100644 index 00000000..4d46259d Binary files /dev/null and b/docs/build/.doctrees/proof_by_refutation_2.doctree differ diff --git a/docs/build/.doctrees/test.doctree b/docs/build/.doctrees/test.doctree new file mode 100644 index 00000000..51623ccb Binary files /dev/null and b/docs/build/.doctrees/test.doctree differ diff --git a/docs/build/.doctrees/universe_of_discourse.doctree b/docs/build/.doctrees/universe_of_discourse.doctree index 71e58053..9e86208a 100644 Binary files a/docs/build/.doctrees/universe_of_discourse.doctree and b/docs/build/.doctrees/universe_of_discourse.doctree differ diff --git a/docs/build/_sources/bibliography.rst.txt b/docs/build/_sources/bibliography.rst.txt index 5bb53430..95a248d6 100644 --- a/docs/build/_sources/bibliography.rst.txt +++ b/docs/build/_sources/bibliography.rst.txt @@ -5,4 +5,4 @@ ************ .. bibliography:: bibliography_bibtex.bib - :style: plain \ No newline at end of file + :cited: diff --git a/docs/build/_sources/disjunction_elimination.rst.txt b/docs/build/_sources/disjunction_elimination.rst.txt new file mode 100644 index 00000000..882ce481 --- /dev/null +++ b/docs/build/_sources/disjunction_elimination.rst.txt @@ -0,0 +1,2 @@ +disjunction-elimination +========================= \ No newline at end of file diff --git a/docs/build/_sources/elimination_rule.rst.txt b/docs/build/_sources/elimination_rule.rst.txt index 1ee0901f..e7f337fc 100644 --- a/docs/build/_sources/elimination_rule.rst.txt +++ b/docs/build/_sources/elimination_rule.rst.txt @@ -7,7 +7,7 @@ Definition An *introduction-rule* is an :doc:`inference_rule` that allows to derive a formula-statement of some syntactic form from some define premises. List of well-known *introduction-rules* --------------------------------------- +------------------------------------------ * :doc:`biconditional_elimination_left` * :doc:`biconditional_elimination_right` diff --git a/docs/build/_sources/formula_statement.rst.txt b/docs/build/_sources/formula_statement.rst.txt new file mode 100644 index 00000000..a17a0f22 --- /dev/null +++ b/docs/build/_sources/formula_statement.rst.txt @@ -0,0 +1,3 @@ +formula-statement +=================== + diff --git a/docs/build/_sources/hypothesis.rst.txt b/docs/build/_sources/hypothesis.rst.txt new file mode 100644 index 00000000..2b184667 --- /dev/null +++ b/docs/build/_sources/hypothesis.rst.txt @@ -0,0 +1,3 @@ +hypothesis +============ + diff --git a/docs/build/_sources/inconsistency_introduction_1.rst.txt b/docs/build/_sources/inconsistency_introduction_1.rst.txt new file mode 100644 index 00000000..bbf34a69 --- /dev/null +++ b/docs/build/_sources/inconsistency_introduction_1.rst.txt @@ -0,0 +1,38 @@ +inconsistency-introduction-1 +======================================== + +Definition +---------- + +*inconsistency-introduction-1* is the :doc:`inference_rule`: + +.. math:: + + \left( P, \neg \left(P\right) \right) \vdash Inc\left(\mathcal{T}\right) + +In straightforward language, if we prove a proposition and its negation, it follows that the theory is inconsistent. + +Quotes +------ + +Python sample usage +---------------------- + +.. admonition:: Source code + :class: tip, dropdown + + .. literalinclude :: ../../sample/code/inconsistency_introduction_1.py + :language: python + :linenos: + +.. admonition:: Unicode output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_1_unicode.txt + :language: text + +.. admonition:: Plaintext output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_1_plaintext.txt + :language: text diff --git a/docs/build/_sources/inconsistency_introduction_2.rst.txt b/docs/build/_sources/inconsistency_introduction_2.rst.txt new file mode 100644 index 00000000..05a783f9 --- /dev/null +++ b/docs/build/_sources/inconsistency_introduction_2.rst.txt @@ -0,0 +1,41 @@ +inconsistency-introduction-2 +======================================== + +Definition +---------- + +*inconsistency-introduction-2* is the :doc:`inference_rule`: + +.. math:: + + \left(\left(x = y\right), \left(x \neq y\right)\right) \vdash Inc\left(\mathcal{T}\right) + +In straightforward language, if we prove both the equality and inequality of two terms, it follows that the theory is inconsistent. + +Quotes +---------- + + A proof of consistency will have to show, by appealing to contentual considerations which are completely unproblematic, that in the formalism in question it is never possible to derive the formula ๐‘Ž โ‰  ๐‘Ž, or alternatively it is not possible to prove both ๐‘Ž = ๐‘ and ๐‘Ž โ‰  ๐‘. :cite:p:`mancosu_2021_introductionprooftheorynormalization{p. 5}` + + +Python sample usage +---------------------- + +.. admonition:: Source code + :class: tip, dropdown + + .. literalinclude :: ../../sample/code/inconsistency_introduction_2.py + :language: python + :linenos: + +.. admonition:: Unicode output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_2_unicode.txt + :language: text + +.. admonition:: Plaintext output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_2_plaintext.txt + :language: text diff --git a/docs/build/_sources/inconsistency_introduction_3.rst.txt b/docs/build/_sources/inconsistency_introduction_3.rst.txt new file mode 100644 index 00000000..9a776ff8 --- /dev/null +++ b/docs/build/_sources/inconsistency_introduction_3.rst.txt @@ -0,0 +1,41 @@ +inconsistency-introduction-3 +======================================== + +Definition +---------- + +*inconsistency-introduction-3* is the :doc:`inference_rule`: + +.. math:: + + \left( P \neq P \right) \vdash Inc\left(\mathcal{T}\right) + +In straightforward language, if we prove that an object is not equal to itself, it follows that the theory is inconsistent. + +Quotes +---------- + + A proof of consistency will have to show, by appealing to contentual considerations which are completely unproblematic, that in the formalism in question it is never possible to derive the formula ๐‘Ž โ‰  ๐‘Ž, or alternatively it is not possible to prove both ๐‘Ž = ๐‘ and ๐‘Ž โ‰  ๐‘. :cite:p:`mancosu_2021_introductionprooftheorynormalization{p. 5}` + + +Python sample usage +---------------------- + +.. admonition:: Source code + :class: tip, dropdown + + .. literalinclude :: ../../sample/code/inconsistency_introduction_3.py + :language: python + :linenos: + +.. admonition:: Unicode output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_3_unicode.txt + :language: text + +.. admonition:: Plaintext output + :class: note, dropdown + + .. literalinclude :: ../../sample/output/inconsistency_introduction_3_plaintext.txt + :language: text diff --git a/docs/build/_sources/index.rst.txt b/docs/build/_sources/index.rst.txt index 89d3d909..b4e2b6c7 100644 --- a/docs/build/_sources/index.rst.txt +++ b/docs/build/_sources/index.rst.txt @@ -13,17 +13,27 @@ Welcome to punctilious's documentation! :maxdepth: 1 :caption: Contents: + test + absorption bibliography + biconditional_elimination_left + biconditional_elimination_right + biconditional_introduction conjunction_elimination_left conjunction_elimination_right conjunction_introduction + disjunction_elimination disjunction_introduction_left disjunction_introduction_right double_negation_elimination double_negation_introduction elimination_rule - inconsistency_by_inequality_introduction + formula_statement + hypothesis + inconsistency_introduction_1 + inconsistency_introduction_2 + inconsistency_introduction_3 inference_rule introduction_rule is_a @@ -31,6 +41,10 @@ Welcome to punctilious's documentation! modus_ponens notation_form paragraph_proof + proof_by_contradiction_1 + proof_by_contradiction_2 + proof_by_refutation_1 + proof_by_refutation_2 relation theory_elaboration_sequence universe_of_discourse diff --git a/docs/build/_sources/introduction_rule.rst.txt b/docs/build/_sources/introduction_rule.rst.txt index 8266c3a0..54cc0a63 100644 --- a/docs/build/_sources/introduction_rule.rst.txt +++ b/docs/build/_sources/introduction_rule.rst.txt @@ -7,7 +7,7 @@ Definition An *introduction-rule* is an :doc:`inference_rule` that allows to derive a formula-statement of some syntactic form from some define premises. List of well-known *introduction-rules* --------------------------------------- +----------------------------------------- * :doc:`biconditional_introduction` * :doc:`conjunction_introduction` diff --git a/docs/build/_sources/proof_by_contradiction_1.rst.txt b/docs/build/_sources/proof_by_contradiction_1.rst.txt new file mode 100644 index 00000000..3ad8c9da --- /dev/null +++ b/docs/build/_sources/proof_by_contradiction_1.rst.txt @@ -0,0 +1,35 @@ +proof-by-contradiction-1 +========================= + +Definition +----------- + +*proof-by-contradiction-1* is the :doc:`inference_rule`: + +.. math:: + + \left( \mathcal{H} assume \not \mathbf{P}, Inc\left(\mathcal{H}\right) \right) \vdash \mathbf{P} + +Python implementation +---------------------- + +Sample usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. literalinclude :: ../../sample/code/proof_by_contradiction_1.py + :language: python + +.. literalinclude :: ../../sample/output/proof_by_contradiction_1_unicode.txt + :language: text + +Documentation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. module:: core + :noindex: +.. autoclass:: InferenceRuleInclusionDict + :members: proof_by_contradiction_1 + +Bibliography +------------ + +.. footbibliography:: \ No newline at end of file diff --git a/docs/build/_sources/proof_by_contradiction_2.rst.txt b/docs/build/_sources/proof_by_contradiction_2.rst.txt new file mode 100644 index 00000000..945a4546 --- /dev/null +++ b/docs/build/_sources/proof_by_contradiction_2.rst.txt @@ -0,0 +1,35 @@ +proof-by-contradiction-2 +========================= + +Definition +---------- + +*proof-by-contradiction-2* is the :doc:`inference_rule`: + +.. math:: + + \left( \mathcal{H} assume \not \mathbf{P}, Inc\left(\mathcal{H}\right) \right) \vdash \mathbf{P} + +Python implementation +--------------------- + +ProofByContradiction2Declaration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. module:: core + :noindex: +.. autoclass:: ProofByContradiction2Declaration + :members: + :special-members: __init__ + +ProofByContradiction2Inclusion +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: ProofByContradiction2Inclusion + :members: + :special-members: __init__ + +Bibliography +------------ + +.. footbibliography:: \ No newline at end of file diff --git a/docs/build/_sources/proof_by_refutation_1.rst.txt b/docs/build/_sources/proof_by_refutation_1.rst.txt new file mode 100644 index 00000000..6a1fb749 --- /dev/null +++ b/docs/build/_sources/proof_by_refutation_1.rst.txt @@ -0,0 +1,41 @@ +proof-by-refutation-1 +========================= + +Definition +---------- + +*proof-by-refutation-1* is the :doc:`inference_rule`: + +.. math:: + + \left( \boldsymbol{\mathcal{H}} \: \textit{assume} \: \neg \boldsymbol{P}, \boldsymbol{P}, Inc\left( \boldsymbol{\mathcal{H}} \right) \right) \vdash \boldsymbol{P} + +Where: + * :math:`\boldsymbol{\mathcal{H}}` is an :doc:`hypothesis` + * :math:`\boldsymbol{P}` is a :doc:`formula_statement` + +In plain language, it consists in posing the hypothesis that a proposition :math:`\boldsymbol{P}` is not true, refuting that hypothesis by proving :math:`\boldsymbol{P}`, inferring the inconsistency of that hypothesis from this contradiction, and finally inferring :math:`\boldsymbol{P}`. + +Python implementation +--------------------- + +ProofByRefutation1Declaration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. module:: core + :noindex: +.. autoclass:: ProofByRefutation1Declaration + :members: + :special-members: __init__ + +ProofByRefutation1Inclusion +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: ProofByRefutation1Inclusion + :members: + :special-members: __init__ + +Bibliography +------------ + +.. footbibliography:: \ No newline at end of file diff --git a/docs/build/_sources/proof_by_refutation_2.rst.txt b/docs/build/_sources/proof_by_refutation_2.rst.txt new file mode 100644 index 00000000..f2d6c818 --- /dev/null +++ b/docs/build/_sources/proof_by_refutation_2.rst.txt @@ -0,0 +1,35 @@ +proof-by-refutation-2 +========================= + +Definition +---------- + +*proof-by-refutation-2* is the :doc:`inference_rule`: + +.. math:: + + \left( \mathcal{H} assume \not \mathbf{P}, Inc\left(\mathcal{H}\right) \right) \vdash \mathbf{P} + +Python implementation +--------------------- + +ProofByRefutation2Declaration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. module:: core + :noindex: +.. autoclass:: ProofByRefutation2Declaration + :members: + :special-members: __init__ + +ProofByRefutation2Inclusion +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. autoclass:: ProofByRefutation2Inclusion + :members: + :special-members: __init__ + +Bibliography +------------ + +.. footbibliography:: \ No newline at end of file diff --git a/docs/build/_sources/test.rst.txt b/docs/build/_sources/test.rst.txt new file mode 100644 index 00000000..8d19f346 --- /dev/null +++ b/docs/build/_sources/test.rst.txt @@ -0,0 +1,5 @@ +minimalist example +===================== + +.. literalinclude :: ../../sample/output/proof_by_contradiction_1_unicode.txt + :language: text \ No newline at end of file diff --git a/docs/build/_static/css/custom.css b/docs/build/_static/css/custom.css new file mode 100644 index 00000000..4b5461c3 --- /dev/null +++ b/docs/build/_static/css/custom.css @@ -0,0 +1,11 @@ +/* +Fix to assure text wrapping in code and code output inclusions implemented with the literalinclude sphinx directive. +References: + - https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html + - https://stackoverflow.com/questions/66971299/sphinx-documentation-with-readthedocs-theme-text-block-wrapping + - https://stackoverflow.com/questions/46800045/how-to-wrap-a-long-literal-block-in-restructuredtext +*/ +pre { + white-space: pre-wrap !important; + word-break: break-all; +} \ No newline at end of file diff --git a/docs/build/_static/togglebutton.css b/docs/build/_static/togglebutton.css new file mode 100644 index 00000000..54a67879 --- /dev/null +++ b/docs/build/_static/togglebutton.css @@ -0,0 +1,160 @@ +/** + * Admonition-based toggles + */ + +/* Visibility of the target */ +.admonition.toggle .admonition-title ~ * { + transition: opacity .3s, height .3s; +} + +/* Toggle buttons inside admonitions so we see the title */ +.admonition.toggle { + position: relative; +} + +/* Titles should cut off earlier to avoid overlapping w/ button */ +.admonition.toggle .admonition-title { + padding-right: 25%; + cursor: pointer; +} + +/* Hovering will cause a slight shift in color to make it feel interactive */ +.admonition.toggle .admonition-title:hover { + box-shadow: inset 0 0 0px 20px rgb(0 0 0 / 1%); +} + +/* Hovering will cause a slight shift in color to make it feel interactive */ +.admonition.toggle .admonition-title:active { + box-shadow: inset 0 0 0px 20px rgb(0 0 0 / 3%); +} + +/* Remove extra whitespace below the admonition title when hidden */ +.admonition.toggle-hidden { + padding-bottom: 0; +} + +.admonition.toggle-hidden .admonition-title { + margin-bottom: 0; +} + +/* hides all the content of a page until de-toggled */ +.admonition.toggle-hidden .admonition-title ~ * { + height: 0; + margin: 0; + opacity: 0; + visibility: hidden; +} + +/* General button style and position*/ +button.toggle-button { + /** + * Background and shape. By default there's no background + * but users can style as they wish + */ + background: none; + border: none; + outline: none; + + /* Positioning just inside the admonition title */ + position: absolute; + right: 0.5em; + padding: 0px; + border: none; + outline: none; +} + +/* Display the toggle hint on wide screens */ +@media (min-width: 768px) { + button.toggle-button.toggle-button-hidden:before { + content: attr(data-toggle-hint); /* This will be filled in by JS */ + font-size: .8em; + align-self: center; + } +} + +/* Icon behavior */ +.tb-icon { + transition: transform .2s ease-out; + height: 1.5em; + width: 1.5em; + stroke: currentColor; /* So that we inherit the color of other text */ +} + +/* The icon should point right when closed, down when open. */ +/* Open */ +.admonition.toggle button .tb-icon { + transform: rotate(90deg); +} + +/* Closed */ +.admonition.toggle button.toggle-button-hidden .tb-icon { + transform: rotate(0deg); +} + +/* With details toggles, we don't rotate the icon so it points right */ +details.toggle-details .tb-icon { + height: 1.4em; + width: 1.4em; + margin-top: 0.1em; /* To center the button vertically */ +} + + +/** + * Details-based toggles. + * In this case, we wrap elements with `.toggle` in a details block. + */ + +/* Details blocks */ +details.toggle-details { + margin: 1em 0; +} + + +details.toggle-details summary { + display: flex; + align-items: center; + cursor: pointer; + list-style: none; + border-radius: .2em; + border-left: 3px solid #1976d2; + background-color: rgb(204 204 204 / 10%); + padding: 0.2em 0.7em 0.3em 0.5em; /* Less padding on left because the SVG has left margin */ + font-size: 0.9em; +} + +details.toggle-details summary:hover { + background-color: rgb(204 204 204 / 20%); +} + +details.toggle-details summary:active { + background: rgb(204 204 204 / 28%); +} + +.toggle-details__summary-text { + margin-left: 0.2em; +} + +details.toggle-details[open] summary { + margin-bottom: .5em; +} + +details.toggle-details[open] summary .tb-icon { + transform: rotate(90deg); +} + +details.toggle-details[open] summary ~ * { + animation: toggle-fade-in .3s ease-out; +} + +@keyframes toggle-fade-in { + from {opacity: 0%;} + to {opacity: 100%;} +} + +/* Print rules - we hide all toggle button elements at print */ +@media print { + /* Always hide the summary so the button doesn't show up */ + details.toggle-details summary { + display: none; + } +} \ No newline at end of file diff --git a/docs/build/_static/togglebutton.js b/docs/build/_static/togglebutton.js new file mode 100644 index 00000000..215a7eef --- /dev/null +++ b/docs/build/_static/togglebutton.js @@ -0,0 +1,187 @@ +/** + * Add Toggle Buttons to elements + */ + +let toggleChevron = ` + + + +`; + +var initToggleItems = () => { + var itemsToToggle = document.querySelectorAll(togglebuttonSelector); + console.log(`[togglebutton]: Adding toggle buttons to ${itemsToToggle.length} items`) + // Add the button to each admonition and hook up a callback to toggle visibility + itemsToToggle.forEach((item, index) => { + if (item.classList.contains("admonition")) { + // If it's an admonition block, then we'll add a button inside + // Generate unique IDs for this item + var toggleID = `toggle-${index}`; + var buttonID = `button-${toggleID}`; + + item.setAttribute('id', toggleID); + if (!item.classList.contains("toggle")){ + item.classList.add("toggle"); + } + // This is the button that will be added to each item to trigger the toggle + var collapseButton = ` + `; + + title = item.querySelector(".admonition-title") + title.insertAdjacentHTML("beforeend", collapseButton); + thisButton = document.getElementById(buttonID); + + // Add click handlers for the button + admonition title (if admonition) + admonitionTitle = document.querySelector(`#${toggleID} > .admonition-title`) + if (admonitionTitle) { + // If an admonition, then make the whole title block clickable + admonitionTitle.addEventListener('click', toggleClickHandler); + admonitionTitle.dataset.target = toggleID + admonitionTitle.dataset.button = buttonID + } else { + // If not an admonition then we'll listen for the button click + thisButton.addEventListener('click', toggleClickHandler); + } + + // Now hide the item for this toggle button unless explicitly noted to show + if (!item.classList.contains("toggle-shown")) { + toggleHidden(thisButton); + } + } else { + // If not an admonition, wrap the block in a
block + // Define the structure of the details block and insert it as a sibling + var detailsBlock = ` +
+ + ${toggleChevron} + ${toggleHintShow} + +
`; + item.insertAdjacentHTML("beforebegin", detailsBlock); + + // Now move the toggle-able content inside of the details block + details = item.previousElementSibling + details.appendChild(item) + item.classList.add("toggle-details__container") + + // Set up a click trigger to change the text as needed + details.addEventListener('click', (click) => { + let parent = click.target.parentElement; + if (parent.tagName.toLowerCase() == "details") { + summary = parent.querySelector("summary"); + details = parent; + } else { + summary = parent; + details = parent.parentElement; + } + // Update the inner text for the proper hint + if (details.open) { + summary.querySelector("span.toggle-details__summary-text").innerText = toggleHintShow; + } else { + summary.querySelector("span.toggle-details__summary-text").innerText = toggleHintHide; + } + + }); + + // If we have a toggle-shown class, open details block should be open + if (item.classList.contains("toggle-shown")) { + details.click(); + } + } + }) +}; + +// This should simply add / remove the collapsed class and change the button text +var toggleHidden = (button) => { + target = button.dataset['target'] + var itemToToggle = document.getElementById(target); + if (itemToToggle.classList.contains("toggle-hidden")) { + itemToToggle.classList.remove("toggle-hidden"); + button.classList.remove("toggle-button-hidden"); + } else { + itemToToggle.classList.add("toggle-hidden"); + button.classList.add("toggle-button-hidden"); + } +} + +var toggleClickHandler = (click) => { + // Be cause the admonition title is clickable and extends to the whole admonition + // We only look for a click event on this title to trigger the toggle. + + if (click.target.classList.contains("admonition-title")) { + button = click.target.querySelector(".toggle-button"); + } else if (click.target.classList.contains("tb-icon")) { + // We've clicked the icon and need to search up one parent for the button + button = click.target.parentElement; + } else if (click.target.tagName == "polyline") { + // We've clicked the SVG elements inside the button, need to up 2 layers + button = click.target.parentElement.parentElement; + } else if (click.target.classList.contains("toggle-button")) { + // We've clicked the button itself and so don't need to do anything + button = click.target; + } else { + console.log(`[togglebutton]: Couldn't find button for ${click.target}`) + } + target = document.getElementById(button.dataset['button']); + toggleHidden(target); +} + +// If we want to blanket-add toggle classes to certain cells +var addToggleToSelector = () => { + const selector = ""; + if (selector.length > 0) { + document.querySelectorAll(selector).forEach((item) => { + item.classList.add("toggle"); + }) + } +} + +// Helper function to run when the DOM is finished +const sphinxToggleRunWhenDOMLoaded = cb => { + if (document.readyState != 'loading') { + cb() + } else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', cb) + } else { + document.attachEvent('onreadystatechange', function() { + if (document.readyState == 'complete') cb() + }) + } +} +sphinxToggleRunWhenDOMLoaded(addToggleToSelector) +sphinxToggleRunWhenDOMLoaded(initToggleItems) + +/** Toggle details blocks to be open when printing */ +if (toggleOpenOnPrint == "true") { + window.addEventListener("beforeprint", () => { + // Open the details + document.querySelectorAll("details.toggle-details").forEach((el) => { + el.dataset["togglestatus"] = el.open; + el.open = true; + }); + + // Open the admonitions + document.querySelectorAll(".admonition.toggle.toggle-hidden").forEach((el) => { + console.log(el); + el.querySelector("button.toggle-button").click(); + el.dataset["toggle_after_print"] = "true"; + }); + }); + window.addEventListener("afterprint", () => { + // Re-close the details that were closed + document.querySelectorAll("details.toggle-details").forEach((el) => { + el.open = el.dataset["togglestatus"] == "true"; + delete el.dataset["togglestatus"]; + }); + + // Re-close the admonition toggle buttons + document.querySelectorAll(".admonition.toggle").forEach((el) => { + if (el.dataset["toggle_after_print"] == "true") { + el.querySelector("button.toggle-button").click(); + delete el.dataset["toggle_after_print"]; + } + }); + }); +} diff --git a/docs/build/absorption.html b/docs/build/absorption.html index 685d41e2..3911a825 100644 --- a/docs/build/absorption.html +++ b/docs/build/absorption.html @@ -10,10 +10,12 @@ + + - +
@@ -38,6 +40,7 @@