Skip to content

Commit

Permalink
build based on 0daeb44
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed May 9, 2024
1 parent 148daf8 commit 2d4eb74
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-22T02:33:46","documenter_version":"1.3.0"}}
{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-09T01:58:35","documenter_version":"1.4.1"}}
2 changes: 1 addition & 1 deletion dev/assets/themes/documenter-dark.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/assets/themes/documenter-light.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · MacroTools</title><meta name="title" content="Home · MacroTools"/><meta property="og:title" content="Home · MacroTools"/><meta property="twitter:title" content="Home · MacroTools"/><meta name="description" content="Documentation for MacroTools."/><meta property="og:description" content="Documentation for MacroTools."/><meta property="twitter:description" content="Documentation for MacroTools."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>MacroTools</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Home</a></li><li><a class="tocitem" href="pattern-matching/">Pattern Matching</a></li><li><a class="tocitem" href="utilities/">Utilities</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/FluxML/MacroTools.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/FluxML/MacroTools.jl/blob/master/docs/src/index.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="MacroTools.jl"><a class="docs-heading-anchor" href="#MacroTools.jl">MacroTools.jl</a><a id="MacroTools.jl-1"></a><a class="docs-heading-anchor-permalink" href="#MacroTools.jl" title="Permalink"></a></h1><p>MacroTools provides a library of tools for working with Julia code and expressions. This includes a powerful template-matching system and code-walking tools that let you do deep transformations of code in a few lines.</p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="pattern-matching/">Pattern Matching »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Friday 22 March 2024 02:33">Friday 22 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · MacroTools</title><meta name="title" content="Home · MacroTools"/><meta property="og:title" content="Home · MacroTools"/><meta property="twitter:title" content="Home · MacroTools"/><meta name="description" content="Documentation for MacroTools."/><meta property="og:description" content="Documentation for MacroTools."/><meta property="twitter:description" content="Documentation for MacroTools."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>MacroTools</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Home</a></li><li><a class="tocitem" href="pattern-matching/">Pattern Matching</a></li><li><a class="tocitem" href="utilities/">Utilities</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/FluxML/MacroTools.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/FluxML/MacroTools.jl/blob/master/docs/src/index.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="MacroTools.jl"><a class="docs-heading-anchor" href="#MacroTools.jl">MacroTools.jl</a><a id="MacroTools.jl-1"></a><a class="docs-heading-anchor-permalink" href="#MacroTools.jl" title="Permalink"></a></h1><p>MacroTools provides a library of tools for working with Julia code and expressions. This includes a powerful template-matching system and code-walking tools that let you do deep transformations of code in a few lines.</p></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="pattern-matching/">Pattern Matching »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <span class="colophon-date" title="Thursday 9 May 2024 01:58">Thursday 9 May 2024</span>. Using Julia version 1.10.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
7 changes: 5 additions & 2 deletions dev/pattern-matching/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
(2,[4,5,6],7)</code></pre><p>Slurps don&#39;t have to be at the end of an expression, but like the Highlander there can only be one (per expression).</p><h3 id="Matching-on-expression-type"><a class="docs-heading-anchor" href="#Matching-on-expression-type">Matching on expression type</a><a id="Matching-on-expression-type-1"></a><a class="docs-heading-anchor-permalink" href="#Matching-on-expression-type" title="Permalink"></a></h3><p><code>@capture</code> can match expressions by their type, which is either the <code>head</code> of <code>Expr</code> objects or the <code>typeof</code> atomic stuff like <code>Symbol</code>s and <code>Int</code>s. For example:</p><pre><code class="language-julia hljs">@capture(ex, foo(x_String_string))</code></pre><p>This will match a call to the <code>foo</code> function which has a single argument, which may either be a <code>String</code> object or a <code>Expr(:string, ...)</code> (e.g. <code>@capture(:(foo(&quot;$(a)&quot;)), foo(x_String_string))</code>). Julia string literals may be parsed into either type of object, so this is a handy way to catch both.</p><p>Another common use case is to catch symbol literals, e.g.</p><pre><code class="language-julia hljs">@capture(ex,
struct T_Symbol
fields__
end)</code></pre><p>which will match e.g. <code>struct Foo ...</code> but not <code>struct Foo{V} ...</code></p><h3 id="Unions"><a class="docs-heading-anchor" href="#Unions">Unions</a><a id="Unions-1"></a><a class="docs-heading-anchor-permalink" href="#Unions" title="Permalink"></a></h3><p><code>@capture</code> can also try to match the expression against one pattern or another, for example:</p><pre><code class="language-julia hljs">@capture(ex, (f_(args__) = body_) | (function f_(args__) body_ end))</code></pre><p>will match both kinds of function syntax (though it&#39;s easier to use <code>shortdef</code> to normalise definitions). You can also do this within expressions, e.g.</p><pre><code class="language-julia hljs">@capture(ex, (f_(args__) where {T_}) | (f_(args__)) = body_)</code></pre><p>matches a function definition like <code>func(a::T) where {T&lt;:Number} = supertype(T)</code>, with a single type parameter bound to <code>T</code> if possible. If not, <code>T = nothing</code>.</p><h2 id="Expression-Walking"><a class="docs-heading-anchor" href="#Expression-Walking">Expression Walking</a><a id="Expression-Walking-1"></a><a class="docs-heading-anchor-permalink" href="#Expression-Walking" title="Permalink"></a></h2><p>If you&#39;ve ever written any more interesting macros, you&#39;ve probably found yourself writing recursive functions to work with nested <code>Expr</code> trees. MacroTools&#39; <code>prewalk</code> and <code>postwalk</code> functions factor out the recursion, making macro code much more concise and robust.</p><p>These expression-walking functions essentially provide a kind of find-and-replace for expression trees. For example:</p><pre><code class="language-julia hljs">julia&gt; using MacroTools: prewalk, postwalk
end)</code></pre><p>which will match e.g. <code>struct Foo ...</code> but not <code>struct Foo{V} ...</code></p><p>If you want to match on quoted symbols like <code>:(:a)</code> you might look at the AST Julia produces and expect to be able to use the type <code>QuoteNode</code> in your pattern. Hence, you would expect the following to produce <code>1</code>:</p><pre><code class="language-julia hljs">@match :(:a) begin
s_QuoteNode =&gt; 1
s_quote =&gt; 2
end</code></pre><p>However, it evaluates to <code>2</code> because MacroTools normalizes expressions before comparing them to your pattern. And <code>QuoteNode</code> gets normalized to <code>quote</code> so to match a quoted symbol you will need <code>@capture(ex, s_quote) &amp;&amp; s.args[1] isa Symbol</code></p><h3 id="Unions"><a class="docs-heading-anchor" href="#Unions">Unions</a><a id="Unions-1"></a><a class="docs-heading-anchor-permalink" href="#Unions" title="Permalink"></a></h3><p><code>@capture</code> can also try to match the expression against one pattern or another, for example:</p><pre><code class="language-julia hljs">@capture(ex, (f_(args__) = body_) | (function f_(args__) body_ end))</code></pre><p>will match both kinds of function syntax (though it&#39;s easier to use <code>shortdef</code> to normalise definitions). You can also do this within expressions, e.g.</p><pre><code class="language-julia hljs">@capture(ex, (f_(args__) where {T_}) | (f_(args__)) = body_)</code></pre><p>matches a function definition like <code>func(a::T) where {T&lt;:Number} = supertype(T)</code>, with a single type parameter bound to <code>T</code> if possible. If not, <code>T = nothing</code>.</p><h2 id="Expression-Walking"><a class="docs-heading-anchor" href="#Expression-Walking">Expression Walking</a><a id="Expression-Walking-1"></a><a class="docs-heading-anchor-permalink" href="#Expression-Walking" title="Permalink"></a></h2><p>If you&#39;ve ever written any more interesting macros, you&#39;ve probably found yourself writing recursive functions to work with nested <code>Expr</code> trees. MacroTools&#39; <code>prewalk</code> and <code>postwalk</code> functions factor out the recursion, making macro code much more concise and robust.</p><p>These expression-walking functions essentially provide a kind of find-and-replace for expression trees. For example:</p><pre><code class="language-julia hljs">julia&gt; using MacroTools: prewalk, postwalk

julia&gt; postwalk(x -&gt; x isa Integer ? x + 1 : x, :(2+3))
:(3 + 4)</code></pre><p>In other words, look at each item in the tree; if it&#39;s an integer, add one, if not, leave it alone.</p><p>We can do more complex things if we combine this with <code>@capture</code>. For example, say we want to insert an extra argument into all function calls:</p><pre><code class="language-julia hljs">julia&gt; ex = quote
Expand Down Expand Up @@ -63,4 +66,4 @@
@capture(x, some_pattern) || return x
return new_x
end
end</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../utilities/">Utilities »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.3.0 on <span class="colophon-date" title="Friday 22 March 2024 02:33">Friday 22 March 2024</span>. Using Julia version 1.10.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
end</code></pre></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../utilities/">Utilities »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <span class="colophon-date" title="Thursday 9 May 2024 01:58">Thursday 9 May 2024</span>. Using Julia version 1.10.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
2 changes: 1 addition & 1 deletion dev/search_index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2d4eb74

Please sign in to comment.