diff options
author | Mike Dalessio <[email protected]> | 2024-10-17 16:40:30 -0400 |
---|---|---|
committer | git <[email protected]> | 2024-10-17 20:40:34 +0000 |
commit | 0b38e184881839d347a777e82ad1b037a1aeca6e (patch) | |
tree | 8b71f0e8b97983d5b97c5772032adfd1c05250b6 /lib/rdoc/generator | |
parent | 48899d56a9c61d4a3e5fe822ed7c16a1f2868bd4 (diff) |
[ruby/rdoc] feature: Render mixed-in methods and constants with
`--embed-mixins`
(https://github.com/ruby/rdoc/pull/842)
* Embed mixed-in methods and constants with `--embed-mixins`
When `--embed-mixins` option is set:
- methods from an `extend`ed module are documented as singleton methods
- attrs from an `extend`ed module are documented as class attributes
- methods from an `include`ed module are documented as instance methods
- attrs from an `include`ed module are documented as instance attributes
- constants from an `include`ed module are documented
Sections are created when needed, and Darkfish's template annotates
each of these mixed-in CodeObjects. We also respect the mixin methods'
visibility.
This feature is inspired by Yard's option of the same name.
* Add comment to document why we set object visibility
Co-authored-by: Stan Lo <[email protected]>
* Add the mixin_from attribute to CodeObject's initializer
* Add test coverage for private mixed-in attributes.
---------
https://github.com/ruby/rdoc/commit/481c2ce660
Co-authored-by: Stan Lo <[email protected]>
Diffstat (limited to 'lib/rdoc/generator')
-rw-r--r-- | lib/rdoc/generator/template/darkfish/class.rhtml | 18 | ||||
-rw-r--r-- | lib/rdoc/generator/template/darkfish/css/rdoc.css | 7 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/rdoc/generator/template/darkfish/class.rhtml b/lib/rdoc/generator/template/darkfish/class.rhtml index 85fb0c1c33..0bec9fc9ce 100644 --- a/lib/rdoc/generator/template/darkfish/class.rhtml +++ b/lib/rdoc/generator/template/darkfish/class.rhtml @@ -54,7 +54,13 @@ <%- constants.each do |const| -%> <dt id="<%= const.name %>"><%= const.name %> <%- if const.comment then -%> - <dd><%= const.description.strip %> + <dd> + <%- if const.mixin_from then -%> + <div class="mixin-from"> + Included from <a href="<%= klass.aref_to(const.mixin_from.path)%>"><%= const.mixin_from.full_name %></a> + </div> + <%- end -%> + <%= const.description.strip %> <%- else -%> <dd class="missing-docs">(Not documented) <%- end -%> @@ -79,6 +85,11 @@ </div> <div class="method-description"> + <%- if attrib.mixin_from then -%> + <div class="mixin-from"> + <%= attrib.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(attrib.mixin_from.path)%>"><%= attrib.mixin_from.full_name %></a> + </div> + <%- end -%> <%- if attrib.comment then -%> <%= attrib.description.strip %> <%- else -%> @@ -145,6 +156,11 @@ <pre><%= method.markup_code %></pre> </div> <%- end -%> + <%- if method.mixin_from then -%> + <div class="mixin-from"> + <%= method.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(method.mixin_from.path)%>"><%= method.mixin_from.full_name %></a> + </div> + <%- end -%> <%- if method.comment then -%> <%= method.description.strip %> <%- else -%> diff --git a/lib/rdoc/generator/template/darkfish/css/rdoc.css b/lib/rdoc/generator/template/darkfish/css/rdoc.css index 49138c6292..a4e1ef188c 100644 --- a/lib/rdoc/generator/template/darkfish/css/rdoc.css +++ b/lib/rdoc/generator/template/darkfish/css/rdoc.css @@ -670,6 +670,13 @@ main .aliases { font-style: italic; cursor: default; } + +main .mixin-from { + font-size: 80%; + font-style: italic; + margin-bottom: 0.75em; +} + main .method-description ul { margin-left: 1.5em; } |