[1] "apple" "banana" "orange"
Adding Documentation Links to Functions in Quarto Code Blocks
code-link option to add documentation links to functions in Quarto code blocks.
Original Japanese version: Quartoのコードブロック内の関数にドキュメントリンクをつける方法
This is a note on how to automatically add documentation links to functions used inside Quarto code blocks. With the code-link option, links can be added to the documentation corresponding to functions inside code blocks.
Add the following setting to the _quarto.yml file.
_quarto.yml
format:
html:
code-link: trueWith this setting, function names in code blocks are displayed with links in HTML output.
Example
When functions are used in inline code or code blocks, links are added automatically. For example, write an R code block as follows.
- Example sentence: If you use the
unique()function like this, you can remove duplicate values from a vector.
Links are also added inside code blocks.
When you hover over each function, an underline appears to indicate that it has a link. Clicking it takes you to the corresponding documentation page. In this example, links are probably added to the c(), unique(), and print() functions.
Notes
- The
code-linkoption is supported only by the knitr engine. Links do not seem to be generated when using other engines, because Quarto internally uses the downlit package. In short, it works only for R code blocks. - It seems that
code-linkcannot be used together with thecode-line-numbersorcode-annotationsoptions. If those options are enabled, thecode-linkoption is ignored.
The code-line-numbers option adds line numbers to code blocks.
The code-annotations option adds annotations to code blocks.