<p>The <code>doi</code> example can be addressed by using the <a href="https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html" rel="nofollow noreferrer">extlinks</a> Sphinx extension, by adding these contents to <code>conf.py</code>:</p>
<pre><code>extlinks = {
    'doi': ('https://dx.doi.org/%s', 'doi:'),
}
</code></pre>
<p>(<a href="https://gist.github.com/jonls/b910afc46473b02597c4#gistcomment-1986251" rel="nofollow noreferrer">Source</a>)</p>
<p>And for <code>arxiv</code>, something similar.</p>
<hr />
<p>For a more generic case, you would need to either</p>
<ol>
<li>create a &quot;custom role&quot;, see for example <a href="https://www.sphinx-doc.org/en/master/development/tutorials/helloworld.html" rel="nofollow noreferrer">https://www.sphinx-doc.org/en/master/development/tutorials/helloworld.html</a> (this tutorial creates a custom directive, but it should be similar), or</li>
<li>find a Sphinx extension that already does it for you.</li>
</ol>
Link directives in Rst grammar
<p>How can I link directive with :doi: or :arxiv: in Rst.</p>
<p>I'm making a document with Rst, but when I try to link with arxiv, it shows broken link.</p>
<p>What I tried is below but not working.</p>
<pre><code>&lt;:doi:`10.1145/2487575.2487591&gt;`
</code></pre>
<p>or</p>
<pre><code>:arxiv:`1309.0238`
</code></pre>