# Documenter: preprocess ?foo to \[\`foo\`\](@ref).. possible?

**URL:** https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494
**Category:** Package Management
**Tags:** question, documentation, documenter
**Created:** [August 29, 2022, 10:45am UTC](https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494 "2022-08-29T10:45:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [August 29, 2022, 10:45am UTC](https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494/1 "2022-08-29T10:45:51Z")

</div>

In my docstrings I often use `"See ?foo for details"`.  
With Documenter, for most sinks this would be better as `"See [`foo`](@ref) for details."`

But that would then look odd if one use the online help of the original function.

Is there any option to preprocess and transform any `?foo` to `[`foo`](@ref)` ?

---

<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: [August 29, 2022, 12:44pm UTC](https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494/2 "2022-08-29T12:44:44Z")

</div>

```julia
repl = r"\?(\w+)" => s"[`\1`](@ref)"
for file in files
    write(f, replace(read(file, String), repl))
end

```

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [August 29, 2022, 3:12pm UTC](https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494/3 "2022-08-29T15:12:37Z")

</div>

Sorry, I thought there could have been a built-in solution. I realised we go back to [this discussion about adding a callback](https://discourse.julialang.org/t/what-do-you-think-add-a-callback-to-documents-page-to-allow-modification-of-md-pages-on-the-fly-before-parsing/79217/7) (and [this pull request](https://github.com/JuliaDocs/Documenter.jl/pull/1798)) to custom preprocess the documentation source.

In that case, I ended up implementing it by using temporary files/directories in the `make.jl` file, but a simple custom function string preprocessing would be much simpler both to implement (that pull request was just 12 line changes) and to use (I have no idea how to implement it at the AST level as suggested by @mortenpi , it seems much more complex…)…

---

<div class="post-metadata">

### Author: ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)
#### Post date: [August 30, 2022, 1:58am UTC](https://discourse.julialang.org/t/documenter-preprocess-foo-to-foo-ref-possible/86494/4 "2022-08-30T01:58:20Z")

</div>

You should be able to do `[`?foo`](@ref foo)`.
