'How to connect asciidoc with source code in gitlab?

I manage my Spring Boot project with Gitlab. ([email protected]:user/project.git).

I keep the documentation in the separate wiki project provided by Gitlab. (so [email protected]:user/project.wiki.git).

Now I want to refer directly from the documentation to the source code in the project and list code snippets for explanation. This way the code would always be up-to-date and you would only have to adapt the explanation if necessary. But how can I link from the wiki project to a remote file? To give an example, this is how it should look later on.

[source,java]
----
include:: https://gitlab.com/user/project/-/raw/master/src/main/java/de/mycompany/project/ProjectApp.java[]
----


Solution 1:[1]

asciidoctor doesn't provide a way to perform remote includes: all include content has to be in the local filesystem.

If you use asciidoctor.js, you could use this extension: https://github.com/feelpp/asciidoctor-remote-include-processor

Otherwise, you could use some form of build coordination, such as make, Ant, etc. to fetch the remote content to a known local location, update your Asciidoc document(s) to include the now-local location, and then run asciidoctor.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eskwayrd