Hi,
How about hook source-read event? You can modify the source file
before parsing with it.
http://www.sphinx-doc.org/en/master/extdev/appapi.html#event-source-read
```
def replace_CMAKE_VERSION(app, docname, source):
source[0] = source[0].replace("CMAKE_VERSION", "v3.13")
def setup(app):
app.connect('source-read', replace_CMAKE_VERSION)
```
I don't test this yet. But it would work well.
>P.S: As a side-topic: I'm unable to find any documentation for the "replace"
>command. What are you using as reference for Sphinx and RST?
here:
http://docutils.sourceforge.net/docs/ref/rst/directives.html#replacement-text
Thanks,
Takeshi KOMIYA
2019年1月10日(木) 1:17 Torsten Robitzki <[email protected]>:
>
> Hello,
> I want to set several links to external documentation (for example
> https://cmake.org/cmake/help/v3.13/command/add_library.html?highlight=add_library#imported-libraries).
> In this example, there is a version number and in case, that this version
> number changes, I don't want to change the links in several places. So I want
> to define the trunk of that link at one place and reuse it. My first thought
> was, I could use `replace::` for that:
>
> .. |CMakeDocumentationRoot| replace:: cmake.org/cmake/help/v3.13/
>
> And then set links like this for example:
>
> .. seealso::
> add_library_
>
> .. _add_library:
> https://|CMakeDocumentationRoot|variable/CMAKE_VERSION.html#variable:CMAKE_VERSION
>
> This doesn't work because the replacement is not done within the link text.
> Second idea was to search for an appropriate plugin. sphinx.ext.extlinks
> would do the trick if the target URLs would be more simple structured.
>
> Does someone of you have an idea, how to include URLs in a documentation,
> which have a common trunk?
>
> Kind regards,
>
> Torsten
>
> P.S: As a side-topic: I'm unable to find any documentation for the "replace"
> command. What are you using as reference for Sphinx and RST?
>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.