[devdocsgjs/main: 1664/1867] Elixir: include source link in section headers
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 1664/1867] Elixir: include source link in section headers
- Date: Fri, 19 Nov 2021 23:48:13 +0000 (UTC)
commit 24ac996ec878dce7ebbb1ef455b2a1538d4f6ddb
Author: Stefan Breunig <stefan-github yrden de>
Date: Mon May 24 10:30:35 2021 +0200
Elixir: include source link in section headers
This implements #763 just for Elixir without solving the general
issue. The style used is similar to the one of the Go docs.
assets/stylesheets/pages/_elixir.scss | 5 +++++
lib/docs/filters/elixir/clean_html.rb | 6 +++++-
lib/docs/filters/elixir/entries.rb | 3 ++-
3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/assets/stylesheets/pages/_elixir.scss b/assets/stylesheets/pages/_elixir.scss
index 4c38e936..240bbd83 100644
--- a/assets/stylesheets/pages/_elixir.scss
+++ b/assets/stylesheets/pages/_elixir.scss
@@ -4,4 +4,9 @@
.type-detail { margin-bottom: 2em; }
.type-detail pre { margin-left: -1rem; }
._mobile & .type-detail pre { margin-left: 0; }
+
+ a.source {
+ float: right;
+ font-size: .9em;
+ }
}
diff --git a/lib/docs/filters/elixir/clean_html.rb b/lib/docs/filters/elixir/clean_html.rb
index 47cec84c..e357f3df 100644
--- a/lib/docs/filters/elixir/clean_html.rb
+++ b/lib/docs/filters/elixir/clean_html.rb
@@ -25,7 +25,7 @@ module Docs
end
def api
- css('.hover-link', '.view-source', 'footer').remove
+ css('.hover-link', 'footer', ':not(.detail-header) > .view-source').remove
css('.summary').each do |node|
node.name = 'dl'
@@ -51,7 +51,11 @@ module Docs
detail.css('.detail-header').each do |node|
node.name = 'h3'
node['id'] = id
+
+ source_href = node.at_css('.view-source').attr('href')
+
node.content = node.at_css('.signature').inner_text
+ node << %(<a href="#{source_href}" class="source">Source</a>)
end
detail.css('.docstring h2').each do |node|
diff --git a/lib/docs/filters/elixir/entries.rb b/lib/docs/filters/elixir/entries.rb
index 24fd9415..91caa237 100644
--- a/lib/docs/filters/elixir/entries.rb
+++ b/lib/docs/filters/elixir/entries.rb
@@ -45,7 +45,8 @@ module Docs
css('.detail-header').map do |node|
id = node['id']
- name = node.content.strip
+ # ignore text of children, i.e. source link
+ name = node.children.select(&:text?).map(&:content).join.strip
name.remove! %r{\(.*\)}
name.remove! 'left '
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]