|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +## |
| 4 | +# Aliki RDoc HTML Generator - A modern documentation theme |
| 5 | +# |
| 6 | +# Based on Darkfish by Michael Granger (ged@FaerieMUD.org) |
| 7 | +# |
| 8 | +# == Description |
| 9 | +# |
| 10 | +# Aliki brings modern design patterns to RDoc documentation with: |
| 11 | +# |
| 12 | +# * Three-column responsive layout (navigation, content, table of contents) |
| 13 | +# * Dark mode support with theme toggle and localStorage persistence |
| 14 | +# * Auto-generated right sidebar TOC with scroll spy (Intersection Observer) |
| 15 | +# * Mobile-optimized search modal with keyboard shortcuts |
| 16 | +# * Enhanced syntax highlighting for light and dark themes |
| 17 | +# * Responsive design with mobile navigation |
| 18 | +# * Zero additional JavaScript dependencies |
| 19 | +# * Modern CSS Grid and Flexbox layout |
| 20 | +# |
| 21 | +# == Usage |
| 22 | +# |
| 23 | +# rdoc --format=aliki --op=doc/ |
| 24 | +# |
| 25 | +# == Author |
| 26 | +# |
| 27 | +# Based on Darkfish by Michael Granger |
| 28 | +# Modernized as Aliki theme by Stan Lo |
| 29 | +# |
| 30 | + |
| 31 | +class RDoc::Generator::Aliki < RDoc::Generator::Darkfish |
| 32 | + |
| 33 | + RDoc::RDoc.add_generator self |
| 34 | + |
| 35 | + ## |
| 36 | + # Version of the Aliki generator |
| 37 | + |
| 38 | + VERSION = '1' |
| 39 | + |
| 40 | + ## |
| 41 | + # Description of this generator |
| 42 | + |
| 43 | + DESCRIPTION = 'Modern HTML generator based on Darkfish' |
| 44 | + |
| 45 | + ## |
| 46 | + # Initialize the Aliki generator with the aliki template directory |
| 47 | + |
| 48 | + def initialize(store, options) |
| 49 | + super |
| 50 | + aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki')) |
| 51 | + @template_dir = Pathname.new(aliki_template_dir) |
| 52 | + end |
| 53 | + |
| 54 | + ## |
| 55 | + # Copy only the static assets required by the Aliki theme. Unlike Darkfish we |
| 56 | + # don't ship embedded fonts or image sprites, so limit the asset list to keep |
| 57 | + # generated documentation lightweight. |
| 58 | + |
| 59 | + def write_style_sheet |
| 60 | + debug_msg "Copying Aliki static files" |
| 61 | + options = { verbose: $DEBUG_RDOC, noop: @dry_run } |
| 62 | + |
| 63 | + install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options |
| 64 | + |
| 65 | + unless @options.template_stylesheets.empty? |
| 66 | + FileUtils.cp @options.template_stylesheets, '.', **options |
| 67 | + end |
| 68 | + |
| 69 | + Dir[(@template_dir + 'js/**/*').to_s].each do |path| |
| 70 | + next if File.directory?(path) |
| 71 | + next if File.basename(path).start_with?('.') |
| 72 | + |
| 73 | + dst = Pathname.new(path).relative_path_from(@template_dir) |
| 74 | + |
| 75 | + install_rdoc_static_file @template_dir + path, dst, options |
| 76 | + end |
| 77 | + end |
| 78 | +end |
0 commit comments