Skip to content

Commit 8915c12

Browse files
authored
Merge pull request #142 from rstudio/feat-rsc-code-block
Feat rsc code block
2 parents 4acf0b8 + 3b5e78c commit 8915c12

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

pins/boards.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,8 @@ def user_name(self):
905905
return self._user_name
906906

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

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

944947
# data preview ----

pins/rsconnect/html/index.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,12 @@ <h3>{{pin_name}}</h3>
4949
<section>
5050
<h3>Code</h3>
5151

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

6056
<script type="text/javascript">
61-
hljs.registerLanguage("r", highlight_r);
57+
hljs.registerLanguage("python", highlight_python);
6258
hljs.initHighlightingOnLoad();
6359
</script>
6460
</section>

pins/tests/_snapshots/test_board_pin_write_rsc_index_html/index.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,12 @@ <h3>derek/test_rsc_pin</h3>
5858
<section>
5959
<h3>Code</h3>
6060

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

6965
<script type="text/javascript">
70-
hljs.registerLanguage("r", highlight_r);
66+
hljs.registerLanguage("python", highlight_python);
7167
hljs.initHighlightingOnLoad();
7268
</script>
7369
</section>

0 commit comments

Comments
 (0)