How to document functions twice?

I want to refer to a function twice in my documentation, once I document the functions per file, and once per category. How can I achieve that?

If I refer to a function in two files like this:

```@docs
plot_cp
plot_four_ex2ep
.```

I get a “duplicate function definition” error.

If I try to refer to a definition in other file I get the following error:

 Error: reference for 'phase_shift()' could not be found in src/topics.md.

Yes, of course not, because it is defined in another file.

How can I solve this issue?

This works:

[`phase_shift`](@ref)

No idea when back ticks are needed and when not.

1 Like

The documentation says:

Text wrapped in backticks will cross-reference a docstring from a @docs block.

(Presumably the rationale here is that backticks are always used when quoting code.)

1 Like

Well, I also need back-ticks for words that contain underscores etc, even if they don’t reference anything…

Right, because you always use backticks in Markdown for code (and things that should be formatted like code, e.g. usernames @ufechner7). The point is that you still use backticks when the code is a link to a cross-reference, not that cross-references are special in this regard.

(I’m not sure under what circumstance you would have a word containing a literal underscore that is not code, but if you wanted this then you need to backslash-escape it in Markdown. For example, underscore\_word is formatted as underscore_word.)

1 Like