Implement source linker and add URL to source code in generated docs.

Long overdue.
This commit is contained in:
KtorZ
2024-08-22 16:37:48 +02:00
parent 44e42d608d
commit b479a289cf
7 changed files with 140 additions and 27 deletions

View File

@@ -220,6 +220,8 @@
<symbol id="icon-menu" viewBox="0 0 24 24"><path d="M3 13h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 7h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1zM3 19h18c0.552 0 1-0.448 1-1s-0.448-1-1-1h-18c-0.552 0-1 0.448-1 1s0.448 1 1 1z"></path></symbol>
<symbol id="icon-external-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></symbol>
<symbol id="icon-moon" viewBox="0 0 24 24"><path d="M21.996 12.882c0.022-0.233-0.038-0.476-0.188-0.681-0.325-0.446-0.951-0.544-1.397-0.219-0.95 0.693-2.060 1.086-3.188 1.162-1.368 0.092-2.765-0.283-3.95-1.158-1.333-0.985-2.139-2.415-2.367-3.935s0.124-3.124 1.109-4.456c0.142-0.191 0.216-0.435 0.191-0.691-0.053-0.55-0.542-0.952-1.092-0.898-2.258 0.22-4.314 1.18-5.895 2.651-1.736 1.615-2.902 3.847-3.137 6.386-0.254 2.749 0.631 5.343 2.266 7.311s4.022 3.313 6.772 3.567 5.343-0.631 7.311-2.266 3.313-4.022 3.567-6.772zM19.567 14.674c-0.49 1.363-1.335 2.543-2.416 3.441-1.576 1.309-3.648 2.016-5.848 1.813s-4.108-1.278-5.417-2.854-2.016-3.648-1.813-5.848c0.187-2.032 1.117-3.814 2.507-5.106 0.782-0.728 1.71-1.3 2.731-1.672-0.456 1.264-0.577 2.606-0.384 3.899 0.303 2.023 1.38 3.934 3.156 5.247 1.578 1.167 3.448 1.668 5.272 1.545 0.752-0.050 1.496-0.207 2.21-0.465z"></path></symbol>
<symbol id="icon-more-horizontal" viewBox="0 0 24 24"><path d="M14 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM21 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414zM7 12c0-0.552-0.225-1.053-0.586-1.414s-0.862-0.586-1.414-0.586-1.053 0.225-1.414 0.586-0.586 0.862-0.586 1.414 0.225 1.053 0.586 1.414 0.862 0.586 1.414 0.586 1.053-0.225 1.414-0.586 0.586-0.862 0.586-1.414z"></path></symbol>

View File

@@ -464,6 +464,22 @@ body.drawer-open .label-closed {
margin: 0 0 0 var(--small-gap);
}
a.member-source,
a.member-source:hover,
a.member-source:visited {
text-decoration: none;
color: var(--color-text-accent);
}
a.member-source::before {
content: '{ ... }';
transition: all 0.5s ease-out;
}
a.member-source:hover::before {
content: '{ view source }';
}
/* Custom type constructors */
.constructor-list {

View File

@@ -56,11 +56,7 @@
</a>
</h2>
{% if !type_info.source_url.is_empty() %}
<!-- TODO: support source linking
<a class="member-source" alt="View Source" title="View Source" href="{{ type_info.source_url|safe }}">
&lt;/&gt;
</a>
-->
<a class="member-source" alt="view source" title="view source" target="_blank" href="{{ type_info.source_url|safe }}"></a>
{% endif %}
</div>
<div class="custom-type-constructors">
@@ -106,11 +102,7 @@
<div class="member-name">
<h2 id="{{ constant.name }}"><pre class="hljs language-aiken">{{ constant.definition }}</pre></h2>
{% if !constant.source_url.is_empty() %}
<!-- TODO: support source linking
<a class="member-source" alt="View Source" title="View Source" href="{{ constant.source_url|safe }}">
&lt;/&gt;
</a>
-->
<a class="member-source" alt="view source" title="view source" target="_blank" href="{{ constant.source_url|safe }}"></a>
{% endif %}
</div>
<div class="rendered-markdown">{{ constant.documentation|safe }}</div>
@@ -131,11 +123,7 @@
<div class="member-name">
<h2 id="{{ function.name }}"><pre class="hljs language-aiken">{{ function.signature }}</pre></h2>
{% if !function.source_url.is_empty() %}
<!-- TODO: support source linking
<a class="member-source" alt="View Source" title="View Source" href="{{ function.source_url|safe }}">
&lt;/&gt;
</a>
-->
<a class="member-source" alt="view source" title="view source" target="_blank" href="{{ function.source_url|safe }}"></a>
{% endif %}
</div>
<div class="rendered-markdown">{{ function.documentation|safe }}</div>