Skip to content

Commit 9a8675a

Browse files
committed
📖 Add RDoc rake tasks, monkeypatches, styles
Prepended modules are to: * Fix `:section:` comments * Convert the "note" list type to tables, like the hanna-nouveau format. Unlike hanna-nouveau, label lists remain lists. * remove redundant "()" from methods Add basic stylesheet tweaks to give more visual separation between methods, make the navbar sticky, fix *bold* font-weight, etc. n.b. some of these styles look best with a couple of rdoc darkfish patches which have not (yet?) been accepted.
1 parent 8c20002 commit 9a8675a

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
# frozen_string_literal: true
2+
13
source "https://rubygems.org"
24

35
gemspec
46

57
gem "rake"
8+
gem "rdoc"
69
gem "test-unit"

docs/styles.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* this is a work in progress. :) */
2+
3+
main .method-header {
4+
background: rgba(27,31,35,0.05);
5+
border: 1px solid #6C8C22;
6+
padding: 0.5em;
7+
border-radius: 4px;
8+
/* padding: 0 0.5em; */
9+
/* border-width: 0 1px; */
10+
/* border-color: #6C8C22; */
11+
/* border-style: solid; */
12+
}
13+
14+
main .method-description, main .aliases {
15+
padding-left: 1em;
16+
}
17+
18+
body {
19+
/*
20+
* The default (300) can be too low contrast. Also, many fonts don't
21+
* distinguish between 300->400, so <em>...</em> had no effect.
22+
*/
23+
font-weight: 400;
24+
}
25+
26+
@media only screen and (min-width: 600px) {
27+
nav {
28+
height: 100%;
29+
position: fixed;
30+
overflow-y: scroll;
31+
}
32+
33+
nav #class-metadata {
34+
margin-bottom: 5em;
35+
}
36+
}

rakelib/rdoc.rake

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# require "sdoc"
2+
require "rdoc/task"
3+
require_relative "../lib/net/imap"
4+
require 'rdoc/rdoc' unless defined?(RDoc::Markup::ToHtml)
5+
6+
module RDoc::Generator
7+
module NetIMAP
8+
9+
module RemoveRedundantParens
10+
def param_seq
11+
super.sub(/^\(\)\s*/, "")
12+
end
13+
end
14+
15+
# See https://github.com/ruby/rdoc/pull/936
16+
module FixSectionComments
17+
def markup(text)
18+
@store ||= @parent&.store
19+
super
20+
end
21+
def description; markup comment end
22+
def comment; super || @comments&.first end
23+
def parse(_comment_location = nil) super() end
24+
end
25+
26+
# render "[label] data" lists as tables. adapted from "hanna-nouveau" gem.
27+
module LabelListTable
28+
def list_item_start(list_item, list_type)
29+
case list_type
30+
when :NOTE
31+
%(<tr><td class='label'>#{Array(list_item.label).map{|label| to_html(label)}.join("<br />")}</td><td>)
32+
else
33+
super
34+
end
35+
end
36+
37+
def list_end_for(list_type)
38+
case list_type
39+
when :NOTE then
40+
"</td></tr>"
41+
else
42+
super
43+
end
44+
end
45+
end
46+
47+
end
48+
end
49+
50+
class RDoc::AnyMethod
51+
prepend RDoc::Generator::NetIMAP::RemoveRedundantParens
52+
end
53+
54+
class RDoc::Context::Section
55+
prepend RDoc::Generator::NetIMAP::FixSectionComments
56+
end
57+
58+
class RDoc::Markup::ToHtml
59+
LIST_TYPE_TO_HTML[:NOTE] = ['<table class="rdoc-list note-list"><tbody>', '</tbody></table>']
60+
prepend RDoc::Generator::NetIMAP::LabelListTable
61+
end
62+
63+
RDoc::Task.new do |doc|
64+
doc.main = "README.md"
65+
doc.title = "net-imap #{Net::IMAP::VERSION}"
66+
doc.rdoc_dir = "doc"
67+
doc.rdoc_files = FileList.new %w[lib/**/*.rb *.rdoc *.md]
68+
doc.options << "--template-stylesheets" << "docs/styles.css"
69+
# doc.generator = "hanna"
70+
end

0 commit comments

Comments
 (0)