Skip to content

Commit 6a01865

Browse files
committed
instruction
1 parent b6564ce commit 6a01865

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CONTRIBUTING.md

+41
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,53 @@ To include code from a file using a direct URL use `!from` operand inside a code
264264

265265
Example:
266266

267+
#### By line number
268+
269+
````markdown
270+
```cadence DepositFees.cdc
271+
!from https://github.com/onflow/flow-core-contracts/blob/master/transactions/FlowServiceAccount/deposit_fees.cdc#L23
272+
```
273+
````
274+
275+
#### By line range
276+
267277
````markdown
268278
```cadence DepositFees.cdc
269279
!from https://github.com/onflow/flow-core-contracts/blob/master/transactions/FlowServiceAccount/deposit_fees.cdc#L23-L26
270280
```
271281
````
272282

283+
#### By snippet name / Region Tag
284+
285+
Specific blocks of code that are embedded in documentation are defined using `[START <snippet_name>]` and `[END <snippet_name>]` region tags.
286+
287+
```ruby
288+
def create_bucket project_id:, bucket_name:
289+
# [START create_bucket]
290+
# project_id = "Your Google Cloud project ID"
291+
# bucket_name = "Your Google Cloud Storage bucket name"
292+
293+
require "google/cloud/storage"
294+
295+
storage = Google::Cloud::Storage.new project: project_id
296+
297+
bucket = storage.create_bucket bucket_name
298+
299+
puts "Created bucket #{bucket.name}"
300+
# [END create_bucket]
301+
end
302+
```
303+
304+
and the reference would look like
305+
306+
````markdown
307+
```ruby
308+
!from https://github.com/emosei/ruby-docs-samples/blob/master/storage/buckets.rb#create_bucket
309+
```
310+
````
311+
312+
313+
273314
This method keeps your documentation synchronized with your codebase by pulling the latest code directly into your docs.
274315

275316

src/plugins/code-reference.js

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const plugin = () => {
118118
}
119119

120120
const lines = getLines(url);
121+
const snippetName = getSnippetName(url);
121122

122123
const fetchPromise = fetch(url)
123124
.then(async (res) => {

0 commit comments

Comments
 (0)