docyard 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/README.md +55 -33
  4. data/lib/docyard/build/asset_bundler.rb +139 -0
  5. data/lib/docyard/build/file_copier.rb +105 -0
  6. data/lib/docyard/build/sitemap_generator.rb +57 -0
  7. data/lib/docyard/build/static_generator.rb +141 -0
  8. data/lib/docyard/builder.rb +104 -0
  9. data/lib/docyard/cli.rb +19 -0
  10. data/lib/docyard/components/table_wrapper_processor.rb +18 -0
  11. data/lib/docyard/config.rb +4 -2
  12. data/lib/docyard/icons/phosphor.rb +1 -0
  13. data/lib/docyard/initializer.rb +80 -14
  14. data/lib/docyard/markdown.rb +13 -0
  15. data/lib/docyard/preview_server.rb +72 -0
  16. data/lib/docyard/rack_application.rb +1 -1
  17. data/lib/docyard/renderer.rb +17 -3
  18. data/lib/docyard/sidebar/config_parser.rb +180 -0
  19. data/lib/docyard/sidebar/item.rb +58 -0
  20. data/lib/docyard/sidebar/renderer.rb +33 -6
  21. data/lib/docyard/sidebar_builder.rb +45 -1
  22. data/lib/docyard/templates/assets/css/components/callout.css +1 -1
  23. data/lib/docyard/templates/assets/css/components/code-block.css +2 -2
  24. data/lib/docyard/templates/assets/css/components/navigation.css +65 -7
  25. data/lib/docyard/templates/assets/css/components/tabs.css +3 -2
  26. data/lib/docyard/templates/assets/css/components/theme-toggle.css +8 -0
  27. data/lib/docyard/templates/assets/css/markdown.css +20 -11
  28. data/lib/docyard/templates/assets/js/components/navigation.js +221 -0
  29. data/lib/docyard/templates/assets/js/theme.js +2 -185
  30. data/lib/docyard/templates/config/docyard.yml.erb +32 -10
  31. data/lib/docyard/templates/layouts/default.html.erb +1 -1
  32. data/lib/docyard/templates/markdown/getting-started/installation.md.erb +46 -12
  33. data/lib/docyard/templates/markdown/guides/configuration.md.erb +202 -0
  34. data/lib/docyard/templates/markdown/guides/markdown-features.md.erb +247 -0
  35. data/lib/docyard/templates/markdown/index.md.erb +55 -59
  36. data/lib/docyard/templates/partials/_nav_group.html.erb +10 -4
  37. data/lib/docyard/templates/partials/_nav_leaf.html.erb +9 -1
  38. data/lib/docyard/version.rb +1 -1
  39. data/lib/docyard.rb +8 -0
  40. metadata +55 -10
  41. data/lib/docyard/templates/markdown/components/callouts.md.erb +0 -204
  42. data/lib/docyard/templates/markdown/components/icons.md.erb +0 -125
  43. data/lib/docyard/templates/markdown/components/tabs.md.erb +0 -686
  44. data/lib/docyard/templates/markdown/configuration.md.erb +0 -202
  45. data/lib/docyard/templates/markdown/core-concepts/file-structure.md.erb +0 -61
  46. data/lib/docyard/templates/markdown/core-concepts/markdown.md.erb +0 -90
  47. data/lib/docyard/templates/markdown/getting-started/introduction.md.erb +0 -30
  48. data/lib/docyard/templates/markdown/getting-started/quick-start.md.erb +0 -56
  49. data/lib/docyard/templates/partials/_icons.html.erb +0 -11
@@ -1,4 +1,5 @@
1
1
  // Docyard Theme JavaScript
2
+ // Handles dark/light theme toggling
2
3
 
3
4
  (function() {
4
5
  'use strict';
@@ -17,193 +18,9 @@
17
18
  });
18
19
  }
19
20
 
20
- function initMobileMenu() {
21
- const toggle = document.querySelector('.secondary-header-menu');
22
- const sidebar = document.querySelector('.sidebar');
23
- const overlay = document.querySelector('.mobile-overlay');
24
-
25
- if (!toggle || !sidebar || !overlay) return;
26
-
27
- function openMenu() {
28
- sidebar.classList.add('is-open');
29
- overlay.classList.add('is-visible');
30
- toggle.setAttribute('aria-expanded', 'true');
31
- document.body.style.overflow = 'hidden';
32
- }
33
-
34
- function closeMenu() {
35
- sidebar.classList.remove('is-open');
36
- overlay.classList.remove('is-visible');
37
- toggle.setAttribute('aria-expanded', 'false');
38
- document.body.style.overflow = '';
39
- }
40
-
41
- function toggleMenu() {
42
- if (sidebar.classList.contains('is-open')) {
43
- closeMenu();
44
- } else {
45
- openMenu();
46
- }
47
- }
48
-
49
- toggle.addEventListener('click', toggleMenu);
50
- overlay.addEventListener('click', closeMenu);
51
-
52
- document.addEventListener('keydown', function(e) {
53
- if (e.key === 'Escape' && sidebar.classList.contains('is-open')) {
54
- closeMenu();
55
- }
56
- });
57
-
58
- sidebar.querySelectorAll('a').forEach(function(link) {
59
- link.addEventListener('click', closeMenu);
60
- });
61
- }
62
-
63
- function initAccordion() {
64
- const toggles = document.querySelectorAll('.nav-group-toggle');
65
-
66
- toggles.forEach(function(toggle) {
67
- toggle.addEventListener('click', function() {
68
- const expanded = toggle.getAttribute('aria-expanded') === 'true';
69
- const children = toggle.nextElementSibling;
70
-
71
- if (!children || !children.classList.contains('nav-group-children')) {
72
- return;
73
- }
74
-
75
- toggle.setAttribute('aria-expanded', !expanded);
76
- children.classList.toggle('collapsed');
77
-
78
- if (expanded) {
79
- children.style.maxHeight = '0';
80
- } else {
81
- children.style.maxHeight = children.scrollHeight + 'px';
82
- }
83
- });
84
- });
85
-
86
- document.querySelectorAll('.nav-group-children.collapsed').forEach(function(el) {
87
- el.style.maxHeight = '0';
88
- });
89
- }
90
-
91
- function initSidebarScroll() {
92
- const scrollContainer = document.querySelector('.sidebar nav');
93
- if (!scrollContainer) return;
94
-
95
- const STORAGE_KEY = 'docyard_sidebar_scroll';
96
- const savedPosition = sessionStorage.getItem(STORAGE_KEY);
97
-
98
- if (savedPosition) {
99
- const position = parseInt(savedPosition, 10);
100
- scrollContainer.scrollTop = position;
101
-
102
- setTimeout(function() {
103
- scrollContainer.scrollTop = position;
104
- }, 100);
105
- } else {
106
- const activeLink = scrollContainer.querySelector('a.active');
107
- if (activeLink) {
108
- setTimeout(function() {
109
- activeLink.scrollIntoView({
110
- behavior: 'instant',
111
- block: 'center'
112
- });
113
- }, 50);
114
- }
115
- }
116
-
117
- scrollContainer.querySelectorAll('a').forEach(function(link) {
118
- link.addEventListener('click', function() {
119
- sessionStorage.setItem(STORAGE_KEY, scrollContainer.scrollTop);
120
- });
121
- });
122
-
123
- let scrollTimeout;
124
- scrollContainer.addEventListener('scroll', function() {
125
- clearTimeout(scrollTimeout);
126
- scrollTimeout = setTimeout(function() {
127
- sessionStorage.setItem(STORAGE_KEY, scrollContainer.scrollTop);
128
- }, 150);
129
- });
130
-
131
- const logo = document.querySelector('.header-logo');
132
- if (logo) {
133
- logo.addEventListener('click', function() {
134
- sessionStorage.removeItem(STORAGE_KEY);
135
- scrollContainer.scrollTop = 0;
136
- });
137
- }
138
- }
139
-
140
- function initScrollBehavior() {
141
- const header = document.querySelector('.header');
142
- const secondaryHeader = document.querySelector('.secondary-header');
143
-
144
- if (!header || !secondaryHeader) return;
145
-
146
- let lastScrollTop = 0;
147
- let ticking = false;
148
-
149
- function isMobile() {
150
- return window.innerWidth <= 1024;
151
- }
152
-
153
- function updateHeaders() {
154
- if (!isMobile()) {
155
- header.classList.remove('hide-on-scroll');
156
- secondaryHeader.classList.remove('shift-up');
157
- ticking = false;
158
- return;
159
- }
160
-
161
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
162
-
163
- if (scrollTop > lastScrollTop && scrollTop > 100) {
164
- header.classList.add('hide-on-scroll');
165
- secondaryHeader.classList.add('shift-up');
166
- } else if (scrollTop < lastScrollTop) {
167
- header.classList.remove('hide-on-scroll');
168
- secondaryHeader.classList.remove('shift-up');
169
- }
170
-
171
- lastScrollTop = scrollTop <= 0 ? 0 : scrollTop;
172
- ticking = false;
173
- }
174
-
175
- window.addEventListener('scroll', function() {
176
- if (!ticking) {
177
- window.requestAnimationFrame(updateHeaders);
178
- ticking = true;
179
- }
180
- });
181
-
182
- window.addEventListener('resize', function() {
183
- if (!isMobile()) {
184
- header.classList.remove('hide-on-scroll');
185
- secondaryHeader.classList.remove('shift-up');
186
- }
187
- });
188
- }
189
-
190
- if ('scrollRestoration' in history) {
191
- history.scrollRestoration = 'manual';
192
- }
193
-
194
21
  if (document.readyState === 'loading') {
195
- document.addEventListener('DOMContentLoaded', function() {
196
- initThemeToggle();
197
- initMobileMenu();
198
- initAccordion();
199
- initSidebarScroll();
200
- initScrollBehavior();
201
- });
22
+ document.addEventListener('DOMContentLoaded', initThemeToggle);
202
23
  } else {
203
24
  initThemeToggle();
204
- initMobileMenu();
205
- initAccordion();
206
- initSidebarScroll();
207
- initScrollBehavior();
208
25
  }
209
26
  })();
@@ -1,20 +1,42 @@
1
1
  # Docyard Configuration
2
- # All fields are optional - remove what you don't need
2
+ # Documentation: https://github.com/yourusername/docyard
3
3
 
4
+ # Site Information
4
5
  site:
5
6
  title: "My Documentation"
6
7
  description: "Documentation for my project"
7
8
 
8
- # Custom branding (paths relative to docs/ directory, or use URLs)
9
+ # Custom Branding (Optional)
10
+ # Paths relative to docs/ directory, or use URLs for CDN-hosted assets
9
11
  branding:
10
- # logo: "assets/logo.svg" # or "https://cdn.example.com/logo.svg" (defaults to Docyard logo)
11
- # logo_dark: "assets/logo-dark.svg" # Dark mode logo (optional)
12
- # favicon: "assets/favicon.svg" # Browser tab icon (defaults to Docyard favicon)
12
+ # logo: "assets/logo.svg" # Light mode logo
13
+ # logo_dark: "assets/logo-dark.svg" # Dark mode logo (optional, falls back to 'logo')
14
+ # favicon: "assets/favicon.svg" # Browser tab icon
13
15
  # appearance:
14
- # logo: true # Show logo (true/false)
15
- # title: true # Show site title (true/false)
16
+ # logo: true # Show logo in header
17
+ # title: true # Show site title in header
16
18
 
19
+ # Sidebar Navigation (Optional)
20
+ # Customize the order and organization of your documentation pages
21
+ # Without this, sidebar is auto-generated from docs/ folder structure
22
+ # sidebar:
23
+ # items:
24
+ # - installation # Simple page reference
25
+ #
26
+ # - guides: # Nested group
27
+ # text: "User Guides"
28
+ # icon: "book-open" # Icon from phosphoricons.com
29
+ # items:
30
+ # - markdown-features
31
+ # - configuration
32
+ #
33
+ # - text: "GitHub" # External link
34
+ # link: "https://github.com/youruser/yourrepo"
35
+ # icon: "github-logo"
36
+ # target: "_blank"
37
+
38
+ # Build Configuration
17
39
  build:
18
- output_dir: "dist"
19
- base_url: "/"
20
- clean: true
40
+ output_dir: "dist" # Output directory for static files
41
+ base_url: "/" # Base URL for deployment (e.g., "/docs/" for subdirectory)
42
+ clean: true # Clean output directory before building
@@ -25,7 +25,7 @@
25
25
  <!-- Primary Header -->
26
26
  <header class="header">
27
27
  <div class="header-content">
28
- <a href="/" class="header-logo">
28
+ <a href="<%= link_path('/') %>" class="header-logo">
29
29
  <% if @display_logo %>
30
30
  <div class="site-logo-container">
31
31
  <% if @logo %>
@@ -1,43 +1,77 @@
1
1
  # Installation
2
2
 
3
- Learn how to install Docyard on your system.
3
+ Get your documentation site up and running in minutes.
4
4
 
5
5
  ## Prerequisites
6
6
 
7
- - Ruby 3.2 or higher
8
- - Bundler (recommended)
7
+ ::: note Requirements
8
+ - Ruby 3.0 or higher
9
+ - Bundler (optional, for Gemfile-based projects)
10
+ :::
9
11
 
10
- ## Install via RubyGems
12
+ Check your Ruby version:
11
13
 
12
14
  ```bash
13
- gem install docyard
15
+ ruby --version
14
16
  ```
15
17
 
18
+ ## Install Docyard
16
19
 
17
- ## Install via Bundler
20
+ :::tabs
21
+ == Gem Install
22
+ ```bash
23
+ gem install docyard
24
+ ```
18
25
 
19
- Add to your Gemfile:
26
+ == Bundler
27
+ Add to your `Gemfile`:
20
28
 
21
29
  ```ruby
22
30
  gem 'docyard'
23
31
  ```
24
32
 
25
-
26
- Then run:
33
+ Then install:
27
34
 
28
35
  ```bash
29
36
  bundle install
30
37
  ```
38
+ :::
31
39
 
32
40
  ## Verify Installation
33
41
 
42
+ Check that Docyard was installed successfully:
43
+
34
44
  ```bash
35
- docyard --version
45
+ docyard version
36
46
  ```
37
47
 
48
+ ## Quick Start
49
+
50
+ Initialize a new documentation project:
51
+
52
+ ```bash
53
+ # Create new project
54
+ docyard init
55
+
56
+ # Start development server
57
+ docyard serve
58
+ ```
59
+
60
+ Visit [http://localhost:4200](http://localhost:4200) to see your documentation.
61
+
62
+ ## Available Commands
38
63
 
39
- You should see the version number printed to your terminal.
64
+ | Command | Description |
65
+ |---------|-------------|
66
+ | `docyard init` | Initialize a new documentation project |
67
+ | `docyard serve` | Start development server with hot reload |
68
+ | `docyard build` | Build static site for production |
69
+ | `docyard preview` | Preview production build locally |
40
70
 
41
71
  ## Next Steps
42
72
 
43
- Now that Docyard is installed, head over to the [Quick Start Guide](quick-start) to create your first documentation site.
73
+ ::: tip What's Next?
74
+ - Explore [Markdown Features](../guides/markdown-features) to see what you can do
75
+ - Learn about [Configuration](../guides/configuration) options
76
+ - Start writing your documentation!
77
+ :::
@@ -0,0 +1,202 @@
1
+ # Configuration
2
+
3
+ Customize your documentation site with `docyard.yml`.
4
+
5
+ ## Getting Started
6
+
7
+ Docyard works without any configuration, but you can customize it by creating a `docyard.yml` file in your project root.
8
+
9
+ ::: tip
10
+ The `docyard init` command creates a `docyard.yml` file with helpful examples.
11
+ :::
12
+
13
+ ## Basic Configuration
14
+
15
+ ```yaml
16
+ site:
17
+ title: "My Documentation"
18
+ description: "Documentation for my project"
19
+ ```
20
+
21
+ ## Branding
22
+
23
+ ### Custom Logo
24
+
25
+ Add your own logo:
26
+
27
+ ```yaml
28
+ branding:
29
+ logo: "assets/logo.svg" # Light mode logo
30
+ logo_dark: "assets/logo-dark.svg" # Dark mode logo (optional)
31
+ favicon: "assets/favicon.svg" # Browser tab icon
32
+ ```
33
+
34
+ ::: note File Paths
35
+ - Paths are relative to the `docs/` directory
36
+ - Or use full URLs: `https://cdn.example.com/logo.svg`
37
+ - Supported formats: SVG, PNG, JPG
38
+ :::
39
+
40
+ ### Logo Visibility
41
+
42
+ Control what appears in the header:
43
+
44
+ ```yaml
45
+ branding:
46
+ appearance:
47
+ logo: true # Show/hide logo
48
+ title: true # Show/hide site title
49
+ ```
50
+
51
+ ## Sidebar Navigation
52
+
53
+ Customize the sidebar structure and order:
54
+
55
+ ```yaml
56
+ sidebar:
57
+ items:
58
+ # Simple page reference
59
+ - installation
60
+
61
+ # Page with custom text
62
+ - quick-start:
63
+ text: "Quick Start Guide"
64
+
65
+ # Page with icon
66
+ - configuration:
67
+ text: "Configuration"
68
+ icon: "gear"
69
+
70
+ # Nested group
71
+ - guides:
72
+ text: "User Guides"
73
+ icon: "book-open"
74
+ items:
75
+ - markdown-features
76
+ - customization
77
+
78
+ # External link
79
+ - text: "GitHub"
80
+ link: "https://github.com/yourusername/yourproject"
81
+ icon: "github-logo"
82
+ target: "_blank"
83
+ ```
84
+
85
+ ::: tip Icons
86
+ Browse available icons at [phosphoricons.com](https://phosphoricons.com). Just use the icon name (e.g., `rocket-launch`, `book-open`).
87
+ :::
88
+
89
+ ### Collapsible Groups
90
+
91
+ Control whether groups start expanded or collapsed:
92
+
93
+ ```yaml
94
+ sidebar:
95
+ items:
96
+ - api:
97
+ text: "API Reference"
98
+ collapsed: true # Start collapsed
99
+ items:
100
+ - authentication
101
+ - endpoints
102
+ - errors
103
+ ```
104
+
105
+ ## Build Configuration
106
+
107
+ Configure the build output:
108
+
109
+ ```yaml
110
+ build:
111
+ output_dir: "dist" # Output directory for built site
112
+ base_url: "/" # Base URL for deployment
113
+ clean: true # Clean output directory before building
114
+ ```
115
+
116
+ ### Base URL
117
+
118
+ Set the base URL for subdirectory deployments:
119
+
120
+ ```yaml
121
+ build:
122
+ base_url: "/docs/" # For example.com/docs/
123
+ ```
124
+
125
+ ::: warning Base URL
126
+ If deploying to a subdirectory, make sure base_url matches your deployment path. Otherwise assets won't load correctly.
127
+ :::
128
+
129
+ ## Complete Example
130
+
131
+ Here's a full configuration file:
132
+
133
+ ```yaml
134
+ site:
135
+ title: "Acme API Documentation"
136
+ description: "Official API documentation for Acme"
137
+
138
+ branding:
139
+ logo: "assets/logo.svg"
140
+ logo_dark: "assets/logo-dark.svg"
141
+ favicon: "assets/favicon.svg"
142
+ appearance:
143
+ logo: true
144
+ title: true
145
+
146
+ sidebar:
147
+ items:
148
+ - index
149
+
150
+ - getting-started:
151
+ text: "Getting Started"
152
+ icon: "rocket-launch"
153
+ items:
154
+ - installation
155
+ - authentication
156
+ - quick-start
157
+
158
+ - guides:
159
+ text: "Guides"
160
+ icon: "book-open"
161
+ items:
162
+ - making-requests
163
+ - error-handling
164
+ - rate-limiting
165
+
166
+ - api:
167
+ text: "API Reference"
168
+ icon: "code"
169
+ collapsed: false
170
+ items:
171
+ - users
172
+ - products
173
+ - orders
174
+
175
+ - text: "GitHub"
176
+ link: "https://github.com/acme/api"
177
+ icon: "github-logo"
178
+ target: "_blank"
179
+
180
+ build:
181
+ output_dir: "dist"
182
+ base_url: "/api/"
183
+ clean: true
184
+ ```
185
+
186
+ ## Configuration Tips
187
+
188
+ ::: tip Best Practices
189
+ 1. **Start simple** - Add configuration as you need it
190
+ 2. **Use icons consistently** - Pick a set and stick with it
191
+ 3. **Organize logically** - Group related pages together
192
+ 4. **Test base_url** - Preview with `docyard preview` before deploying
193
+ 5. **Keep it maintainable** - Don't over-configure
194
+ :::
195
+
196
+ ## Next Steps
197
+
198
+ ::: note
199
+ - Learn about [markdown features](markdown-features)
200
+ - Check the [installation guide](../getting-started/installation)
201
+ - Start customizing your site!
202
+ :::