Skip to content

Commit

Permalink
Fix embed-n2 extension (#13)
Browse files Browse the repository at this point in the history
* Adjusted N2 default size and path to fix it, also bumped version

* Fixed embed-n2 docstring for toolbar change
  • Loading branch information
eytanadler committed Aug 6, 2022
1 parent 4a60958 commit 4ba9570
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sphinx_mdolab_theme/__init__.py
Expand Up @@ -2,7 +2,7 @@
import sphinx


__version__ = "1.4.1"
__version__ = "1.4.2"
__version_full__ = __version__


Expand Down
18 changes: 9 additions & 9 deletions sphinx_mdolab_theme/ext/embed_n2.py
Expand Up @@ -22,15 +22,15 @@ class EmbedN2Directive(Directive):
The one required argument is the model file to be diagrammed.
Optional arguments are numerical width and height of the embedded object, and
"toolbar" if the toolbar should be visible by default.
"no-toolbar" if the toolbar should be hidden by default.
Example with width of 1500, height of 800, and toolbar displayed:
Example with width of 1500, height of 800, and toolbar hidden:
.. embed-n2:
../../examples/model.py
1500
800
toolbar
no-toolbar
"""

Expand All @@ -40,14 +40,14 @@ class EmbedN2Directive(Directive):

def run(self):
path_to_model = self.arguments[0]
n2_dims = [1200, 700]
show_toolbar = False
n2_dims = [900, 620]
show_toolbar = True

if len(self.arguments) > 1 and self.arguments[1]:
n2_dim_idx = 0
for idx in range(1, len(self.arguments)):
if self.arguments[idx] == "toolbar":
show_toolbar = True
if self.arguments[idx] == "no-toolbar":
show_toolbar = False
else:
n2_dims[n2_dim_idx] = self.arguments[idx]
n2_dim_idx = 1
Expand All @@ -61,7 +61,7 @@ def run(self):
# Generate N2 files into the target_dir. Those files are later copied
# into the top of the HTML hierarchy, so the HTML doc file needs a
# relative path to them.
target_dir = os.path.join(os.getcwd(), "_n2html")
target_dir = os.path.join(os.getcwd(), "_build/html")

rel_dir = os.path.relpath(os.getcwd(), os.path.dirname(self.state.document.settings._source))
html_base_name = os.path.basename(path_to_model).split(".")[0] + "_n2.html"
Expand All @@ -84,7 +84,7 @@ def run(self):
object_tag = (
"<iframe width='" + str(n2_dims[0]) + "'"
" height='" + str(n2_dims[1]) + "'"
" style='border: 1px solid lightgray; resize: both;'"
" style='border: 0px solid lightgray; resize: both;'"
" src='" + html_rel_name + "'></iframe>"
)

Expand Down

0 comments on commit 4ba9570

Please sign in to comment.