This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
_recipe-template.qmd
150 lines (100 loc) Β· 4.56 KB
/
_recipe-template.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
title: Recipe Title
---
## Problem
[Describe what the recipe does or set up the problem the user can solve with it, e.g., "You need to assign tags to content on your Connect server" or "You want to organize content on Connect."]
## Solution
[Describe the solution in natural language. If the workflow is common between Python and R, describe it outside language tabs, but if they're significantly different, describe it in language-specific sections.
The recipe should describe the inputs, workflow, and outputs, but doesn't need to follow a specific format for listing them out. Shorter recipes might just require a code block, and others might require more detail.]
E.g. Assign a tag to your content. This requires obtaining the content item's unique identifier. See [Getting a content identifier](#some-other-section).
:::{.panel-tabset group="language"}
## Python
[Describe the language-specific parts of the workflow inside language tabs, e.g. "This recipe requires the identifier of the tag you wish to use"]
```{.python}
# Notes to recipe writer:
# - Include comments where appropriate. If comments are longer than a line
# or two, you can break up the code block.
# - Include the imports and client creation at the top of the workflow.
# - The recipe should ideally end with the creation of an object representing
# the output of the workflow, which is printed in a subsequent block.
from posit import connect
# Note to recipe writer: User-defined constants go in all-caps, immediately
# after the import statements. Consider using comments to make it obvious
# what the values are and how to get them even if the code has been copied
# out of the recipe page.
# 1. Specify abc. Any clarifying text and what the default value is (if any).
ABC = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
# 2. Specify xyz. Any clarifying text and what the default value is (if any).
XYZ = "23"
client = connect.Client()
new_var = do_something(ABC, XYZ)
```
[You may use multiple code blocks, separated by prose, if your example needs a lot of explanation.]
```{.python}
# Second code block
output_df = function(ABC, new_var)
```
[Describe the output, e.g. "The recipe produces a data frame of outputs." When displaying outputs, display the output from an interactive session.]
```{.python}
# Note to recipe writer: print the result of the recipe in a REPL/console
# style code block.
>>> output_df
[output printout]
```
### [Optional] Full example
[If the recipe includes multiple code blocks, include a section with all the code in a single copyable block.]
```{.python}
from posit import connect
# Define inputs
ABC = "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
XYZ = "23"
client = connect.Client()
new_var = do_something(ABC, XYZ)
output_df = function(ABC, new_var)
```
## R
```{.r}
# Notes to recipe writer:
# - Include comments where appropriate. If comments are longer than a line
# or two, you can break up the code block.
# - Include the imports and client creation at the top of the workflow.
# - The recipe should ideally end with the creation of an object representing
# the output of the workflow, which is printed in a subsequent block.
library(connectapi)
# Note to recipe writer: User-defined constants go in all-caps, immediately
# after the import statements. Consider using comments to make it obvious
# what the values are and how to get them even if the code has been copied
# out of the recipe page.
# 1. Specify abc. Any clarifying text and what the default value is (if any).
ABC <- "154bd2af-e8fa-4aa4-aab8-dcef701f4af9"
# 2. Specify xyz. Any clarifying text and what the default value is (if any).
XYZ <- "23"
client <- connect()
new_var <- do_something(ABC, XYZ)
output_df <- function(ABC, new_var)
```
[Describe the output, e.g. "The recipe produces a data frame of outputs." When displaying outputs, display the output from an interactive session.]
```{.r}
# Note to recipe writer: print the result of the recipe in a REPL/console
# style code block.
> output_df
[1] "xyz"
```
:::
### [Optional additional subheadings, e.g. Deploy a dashboard to monitor usage]
[Some recipes may have additional sections. These might have more language blocks. They might describe other related workflows, or provide supplemental material like tashboards to deploy.]
E.g. Here's a dashboard or something else that deploy or do.
:::{.panel-tabset group="language"}
## Python
```{.python}
hello_world()
```
## R
```{.r}
hello_world()
```
:::
## [Optional] Discussion
Optionally give more detail on the subject at hand.
## [Optional] See also
Optionally link to other sections of the Posit Connect documentation.