Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Dec 11, 2021
1 parent 77aaff0 commit c39d132
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/src/features/code_src.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@code_src` macro

The macro allows you to display source code of a method in-line,
just like `@code_llvm` and `@code_typed`. Inspired by:
https://github.com/JuliaLang/julia/issues/2625#issuecomment-498840808

```julia-repl
julia> @code_src sum(1:3)
function sum(r::AbstractRange{<:Real})
l = length(r)
# note that a little care is required to avoid overflow in l*(l-1)/2
return l * first(r) + (iseven(l) ? (step(r) * (l-1)) * (l>>1)
: (step(r) * l) * ((l-1)>>1))
end
```
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Pages = [
"features/rainbow_brackets.md",
"features/markdown_highlight.md",
"features/fzf.md",
"features/code_src.md",
"internals/passes.md"
]
Depth = 1
Expand Down

0 comments on commit c39d132

Please sign in to comment.