# Extracting Documenter.jl examples for precompilation

**URL:** <https://discourse.julialang.org/t/extracting-documenter-jl-examples-for-precompilation/101234>\
**Category:** Tooling\
**Tags:** package, documentation, precompilation\
**Created:** [July 6, 2023, 1:09am UTC](https://discourse.julialang.org/t/extracting-documenter-jl-examples-for-precompilation/101234 "2023-07-06T01:09:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 6, 2023, 1:09am UTC](https://discourse.julialang.org/t/extracting-documenter-jl-examples-for-precompilation/101234/1 "2023-07-06T01:09:40Z")

</div>

Is there any method to go through all `@example` blocks in the documentation of a package, extract self-contained scripts that were written by the author, and then use these scripts for precompilation of the package?

I am trying to avoid code repetition, and since I am already writing docs for the most common use cases of the package, I would like to take these use cases and precompile during package installation.

Anyone has thoughts or a proof of concept for this?

cc: @mortenpi @fredrikekre

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [July 6, 2023, 3:55am UTC](https://discourse.julialang.org/t/extracting-documenter-jl-examples-for-precompilation/101234/2 "2023-07-06T03:55:13Z")

</div>

I don’t think so.

My first reaction is that this would become a very heavy precompile load though. Likely it is better to identify what needs precompiling and target that more surgically.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 6, 2023, 11:00am UTC](https://discourse.julialang.org/t/extracting-documenter-jl-examples-for-precompilation/101234/3 "2023-07-06T11:00:49Z")

</div>

We have named examples with Documenter.jl, so we could select just those with a given name:

````julia
```@example precompile
...

````

Can we extract all these named examples somehow and place into a big script for precompilation?
