Skip to content

Commit

Permalink
Merge pull request #142 from rstudio/feat-rsc-code-block
Browse files Browse the repository at this point in the history
Feat rsc code block
  • Loading branch information
machow authored Jun 24, 2022
2 parents 4acf0b8 + 3b5e78c commit 8915c12
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
3 changes: 3 additions & 0 deletions pins/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ def user_name(self):
return self._user_name

def prepare_pin_version(self, pin_dir_path, x, name: "str | None", *args, **kwargs):
# TODO: should move board_deparse into utils, to avoid circular import
from .constructors import board_deparse

# RSC pin names can have form <user_name>/<name>, but this will try to
# create the object in a directory named <user_name>. So we grab just
Expand Down Expand Up @@ -939,6 +941,7 @@ def prepare_pin_version(self, pin_dir_path, x, name: "str | None", *args, **kwar
"pin_name": self.path_to_pin(name),
"pin_files": pin_files,
"pin_metadata": meta,
"board_deparse": board_deparse(self),
}

# data preview ----
Expand Down
12 changes: 4 additions & 8 deletions pins/rsconnect/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,12 @@ <h3>{{pin_name}}</h3>
<section>
<h3>Code</h3>

<!-- TODO: how to handle this?
<pre id="pin-r" class="pin-code"><code class="r">library(pins)
board <- {{board_deparse}}
pin_read(board, "{{pin_name}}")</code></pre>
!-->
<pre id="pin-python" class="pin-code"><code class="python">from pins import board_rsconnect
board = {{board_deparse}}
board.pin_read("{{pin_name}}")</code></pre>

<script type="text/javascript">
hljs.registerLanguage("r", highlight_r);
hljs.registerLanguage("python", highlight_python);
hljs.initHighlightingOnLoad();
</script>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ <h3>derek/test_rsc_pin</h3>
<section>
<h3>Code</h3>

<!-- TODO: how to handle this?
<pre id="pin-r" class="pin-code"><code class="r">library(pins)
board <-
pin_read(board, "derek/test_rsc_pin")</code></pre>
!-->
<pre id="pin-python" class="pin-code"><code class="python">from pins import board_rsconnect
board = board_rsconnect(server_url='http://localhost:3939')
board.pin_read("derek/test_rsc_pin")</code></pre>

<script type="text/javascript">
hljs.registerLanguage("r", highlight_r);
hljs.registerLanguage("python", highlight_python);
hljs.initHighlightingOnLoad();
</script>
</section>
Expand Down

0 comments on commit 8915c12

Please sign in to comment.