docyard 0.9.0 → 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/README.md +8 -253
- data/exe/docyard +6 -0
- data/lib/docyard/build/asset_bundler.rb +2 -2
- data/lib/docyard/build/file_copier.rb +12 -5
- data/lib/docyard/build/llms_txt_generator.rb +103 -0
- data/lib/docyard/build/sitemap_generator.rb +1 -1
- data/lib/docyard/build/static_generator.rb +115 -79
- data/lib/docyard/builder.rb +6 -2
- data/lib/docyard/cli.rb +14 -4
- data/lib/docyard/components/processors/callout_processor.rb +1 -1
- data/lib/docyard/components/processors/code_block_extended_fence_postprocessor.rb +24 -0
- data/lib/docyard/components/processors/code_block_extended_fence_preprocessor.rb +44 -0
- data/lib/docyard/components/processors/code_block_options_preprocessor.rb +11 -1
- data/lib/docyard/components/processors/code_block_processor.rb +5 -24
- data/lib/docyard/components/processors/code_group_processor.rb +6 -22
- data/lib/docyard/components/processors/code_snippet_import_preprocessor.rb +1 -0
- data/lib/docyard/components/processors/file_tree_processor.rb +1 -2
- data/lib/docyard/components/processors/icon_processor.rb +8 -2
- data/lib/docyard/components/processors/include_processor.rb +10 -10
- data/lib/docyard/components/processors/video_embed_processor.rb +14 -3
- data/lib/docyard/components/support/code_block/feature_extractor.rb +3 -1
- data/lib/docyard/components/support/code_block/icon_detector.rb +5 -12
- data/lib/docyard/components/support/code_block/line_number_resolver.rb +30 -0
- data/lib/docyard/components/support/code_detector.rb +2 -12
- data/lib/docyard/components/support/code_group/html_builder.rb +2 -6
- data/lib/docyard/components/support/tabs/icon_detector.rb +6 -2
- data/lib/docyard/components/support/tabs/parser.rb +6 -23
- data/lib/docyard/config/analytics_resolver.rb +24 -0
- data/lib/docyard/config/branding_resolver.rb +58 -27
- data/lib/docyard/config/key_validator.rb +30 -0
- data/lib/docyard/config/logo_detector.rb +8 -8
- data/lib/docyard/config/schema.rb +39 -0
- data/lib/docyard/config/section.rb +21 -0
- data/lib/docyard/config/validation_helpers.rb +83 -0
- data/lib/docyard/config/validator.rb +45 -144
- data/lib/docyard/config/validators/navigation.rb +43 -0
- data/lib/docyard/config/validators/section.rb +114 -0
- data/lib/docyard/config.rb +46 -102
- data/lib/docyard/constants.rb +59 -0
- data/lib/docyard/{utils/errors.rb → errors.rb} +6 -0
- data/lib/docyard/initializer.rb +100 -49
- data/lib/docyard/navigation/page_navigation_builder.rb +65 -0
- data/lib/docyard/navigation/sidebar/auto_builder.rb +107 -0
- data/lib/docyard/navigation/sidebar/cache.rb +96 -0
- data/lib/docyard/navigation/sidebar/config_builder.rb +179 -0
- data/lib/docyard/navigation/sidebar/distributed_builder.rb +145 -0
- data/lib/docyard/navigation/sidebar/local_config_loader.rb +69 -3
- data/lib/docyard/navigation/sidebar/renderer.rb +12 -1
- data/lib/docyard/navigation/sidebar_builder.rb +43 -81
- data/lib/docyard/rendering/branding_variables.rb +65 -0
- data/lib/docyard/rendering/icon_helpers.rb +14 -1
- data/lib/docyard/rendering/icons/devicons.rb +63 -0
- data/lib/docyard/rendering/icons.rb +26 -27
- data/lib/docyard/rendering/markdown.rb +5 -23
- data/lib/docyard/rendering/og_helpers.rb +36 -0
- data/lib/docyard/rendering/renderer.rb +87 -59
- data/lib/docyard/rendering/template_resolver.rb +14 -0
- data/lib/docyard/routing/fallback_resolver.rb +3 -3
- data/lib/docyard/search/build_indexer.rb +2 -2
- data/lib/docyard/search/dev_indexer.rb +36 -28
- data/lib/docyard/search/pagefind_support.rb +1 -1
- data/lib/docyard/server/asset_handler.rb +39 -15
- data/lib/docyard/server/dev_server.rb +90 -55
- data/lib/docyard/server/file_watcher.rb +68 -18
- data/lib/docyard/server/pagefind_handler.rb +1 -1
- data/lib/docyard/server/preview_server.rb +29 -33
- data/lib/docyard/server/rack_application.rb +38 -70
- data/lib/docyard/server/router.rb +11 -7
- data/lib/docyard/server/sse_server.rb +157 -0
- data/lib/docyard/server/static_file_app.rb +42 -0
- data/lib/docyard/templates/assets/css/components/banner.css +31 -0
- data/lib/docyard/templates/assets/css/components/breadcrumbs.css +2 -1
- data/lib/docyard/templates/assets/css/components/callout.css +26 -6
- data/lib/docyard/templates/assets/css/components/code-block.css +4 -2
- data/lib/docyard/templates/assets/css/components/code-group.css +20 -7
- data/lib/docyard/templates/assets/css/components/feedback.css +126 -0
- data/lib/docyard/templates/assets/css/components/file-tree.css +5 -4
- data/lib/docyard/templates/assets/css/components/icon.css +5 -0
- data/lib/docyard/templates/assets/css/components/nav-menu.css +20 -4
- data/lib/docyard/templates/assets/css/components/navigation.css +25 -3
- data/lib/docyard/templates/assets/css/components/page-actions.css +131 -0
- data/lib/docyard/templates/assets/css/components/prev-next.css +14 -7
- data/lib/docyard/templates/assets/css/components/search.css +6 -10
- data/lib/docyard/templates/assets/css/components/tab-bar.css +7 -4
- data/lib/docyard/templates/assets/css/components/table-of-contents.css +57 -11
- data/lib/docyard/templates/assets/css/components/tabs.css +12 -4
- data/lib/docyard/templates/assets/css/components/theme-toggle.css +3 -1
- data/lib/docyard/templates/assets/css/landing.css +82 -13
- data/lib/docyard/templates/assets/css/layout.css +17 -0
- data/lib/docyard/templates/assets/css/markdown.css +22 -2
- data/lib/docyard/templates/assets/css/variables.css +13 -1
- data/lib/docyard/templates/assets/js/components/code-group.js +4 -1
- data/lib/docyard/templates/assets/js/components/copy-page.js +115 -0
- data/lib/docyard/templates/assets/js/components/feedback.js +66 -0
- data/lib/docyard/templates/assets/js/components/file-tree.js +5 -5
- data/lib/docyard/templates/assets/js/components/navigation.js +3 -3
- data/lib/docyard/templates/assets/js/components/search.js +3 -3
- data/lib/docyard/templates/assets/js/components/table-of-contents.js +12 -6
- data/lib/docyard/templates/assets/js/components/tabs.js +45 -22
- data/lib/docyard/templates/assets/js/components/tooltip.js +4 -4
- data/lib/docyard/templates/assets/js/hot-reload.js +44 -0
- data/lib/docyard/templates/errors/404.html.erb +114 -5
- data/lib/docyard/templates/errors/500.html.erb +173 -10
- data/lib/docyard/templates/init/_sidebar.yml +36 -0
- data/lib/docyard/templates/init/docyard.yml +36 -0
- data/lib/docyard/templates/init/pages/components.md +146 -0
- data/lib/docyard/templates/init/pages/getting-started.md +94 -0
- data/lib/docyard/templates/init/pages/index.md +22 -0
- data/lib/docyard/templates/layouts/default.html.erb +10 -0
- data/lib/docyard/templates/layouts/splash.html.erb +14 -1
- data/lib/docyard/templates/partials/_analytics.html.erb +24 -0
- data/lib/docyard/templates/partials/_banner.html.erb +1 -1
- data/lib/docyard/templates/partials/_code_block.html.erb +1 -1
- data/lib/docyard/templates/partials/_feedback.html.erb +14 -0
- data/lib/docyard/templates/partials/_footer.html.erb +1 -1
- data/lib/docyard/templates/partials/_head.html.erb +79 -4
- data/lib/docyard/templates/partials/_icon_library.html.erb +8 -0
- data/lib/docyard/templates/partials/_page_actions.html.erb +21 -0
- data/lib/docyard/templates/partials/_scripts.html.erb +6 -3
- data/lib/docyard/templates/partials/_tabs.html.erb +4 -1
- data/lib/docyard/utils/git_info.rb +157 -0
- data/lib/docyard/utils/hash_utils.rb +31 -0
- data/lib/docyard/utils/html_helpers.rb +8 -0
- data/lib/docyard/utils/logging.rb +44 -3
- data/lib/docyard/utils/path_resolver.rb +0 -10
- data/lib/docyard/utils/path_utils.rb +73 -0
- data/lib/docyard/version.rb +1 -1
- data/lib/docyard.rb +2 -2
- metadata +77 -47
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- data/.github/pull_request_template.md +0 -14
- data/.github/workflows/ci.yml +0 -49
- data/.rubocop.yml +0 -42
- data/CODE_OF_CONDUCT.md +0 -132
- data/CONTRIBUTING.md +0 -55
- data/LICENSE.vscode-icons +0 -42
- data/Rakefile +0 -8
- data/lib/docyard/config/constants.rb +0 -31
- data/lib/docyard/navigation/sidebar/children_discoverer.rb +0 -51
- data/lib/docyard/navigation/sidebar/config_parser.rb +0 -208
- data/lib/docyard/navigation/sidebar/file_resolver.rb +0 -90
- data/lib/docyard/navigation/sidebar/file_system_scanner.rb +0 -78
- data/lib/docyard/navigation/sidebar/metadata_extractor.rb +0 -71
- data/lib/docyard/navigation/sidebar/metadata_reader.rb +0 -51
- data/lib/docyard/navigation/sidebar/path_prefixer.rb +0 -34
- data/lib/docyard/navigation/sidebar/sorter.rb +0 -21
- data/lib/docyard/navigation/sidebar/title_extractor.rb +0 -25
- data/lib/docyard/navigation/sidebar/tree_builder.rb +0 -140
- data/lib/docyard/rendering/icons/LICENSE.phosphor +0 -21
- data/lib/docyard/rendering/icons/file_types.rb +0 -79
- data/lib/docyard/rendering/icons/phosphor.rb +0 -93
- data/lib/docyard/rendering/language_mapping.rb +0 -52
- data/lib/docyard/templates/assets/js/reload.js +0 -98
- data/lib/docyard/templates/partials/_icon.html.erb +0 -1
- data/lib/docyard/templates/partials/_icon_file_extension.html.erb +0 -1
- data/sig/docyard.rbs +0 -4
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature Request
|
|
3
|
-
about: Suggest a feature
|
|
4
|
-
title: ''
|
|
5
|
-
labels: enhancement
|
|
6
|
-
assignees: ''
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Description
|
|
10
|
-
|
|
11
|
-
<!-- What feature would you like? -->
|
|
12
|
-
|
|
13
|
-
## Use Case
|
|
14
|
-
|
|
15
|
-
<!-- Why is this useful? When would you use it? -->
|
|
16
|
-
|
|
17
|
-
## Implementation Ideas
|
|
18
|
-
|
|
19
|
-
<!-- Optional: How might this work? -->
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
name: Ruby ${{ matrix.ruby }} - Test
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
strategy:
|
|
14
|
-
fail-fast: false
|
|
15
|
-
matrix:
|
|
16
|
-
ruby: ['3.2', '3.3', '3.4', 'head']
|
|
17
|
-
continue-on-error: ${{ matrix.ruby == 'head' }}
|
|
18
|
-
|
|
19
|
-
steps:
|
|
20
|
-
- name: Checkout code
|
|
21
|
-
uses: actions/checkout@v4
|
|
22
|
-
|
|
23
|
-
- name: Set up Ruby
|
|
24
|
-
uses: ruby/setup-ruby@v1
|
|
25
|
-
with:
|
|
26
|
-
ruby-version: ${{ matrix.ruby }}
|
|
27
|
-
bundler-cache: true
|
|
28
|
-
|
|
29
|
-
- name: Run tests
|
|
30
|
-
run: bundle exec rspec
|
|
31
|
-
env:
|
|
32
|
-
RUBYOPT: '-W0'
|
|
33
|
-
|
|
34
|
-
lint:
|
|
35
|
-
name: Rubocop
|
|
36
|
-
runs-on: ubuntu-latest
|
|
37
|
-
|
|
38
|
-
steps:
|
|
39
|
-
- name: Checkout code
|
|
40
|
-
uses: actions/checkout@v4
|
|
41
|
-
|
|
42
|
-
- name: Set up Ruby
|
|
43
|
-
uses: ruby/setup-ruby@v1
|
|
44
|
-
with:
|
|
45
|
-
ruby-version: '3.3'
|
|
46
|
-
bundler-cache: true
|
|
47
|
-
|
|
48
|
-
- name: Run rubocop
|
|
49
|
-
run: bundle exec rubocop
|
data/.rubocop.yml
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
plugins:
|
|
2
|
-
- rubocop-rspec
|
|
3
|
-
- rubocop-rake
|
|
4
|
-
|
|
5
|
-
AllCops:
|
|
6
|
-
NewCops: enable
|
|
7
|
-
TargetRubyVersion: 3.2
|
|
8
|
-
Exclude:
|
|
9
|
-
- 'vendor/**/*'
|
|
10
|
-
- 'spec/fixtures/**/*'
|
|
11
|
-
- 'tmp/**/*'
|
|
12
|
-
|
|
13
|
-
Metrics/BlockLength:
|
|
14
|
-
Exclude:
|
|
15
|
-
- 'spec/**/*'
|
|
16
|
-
- '*.gemspec'
|
|
17
|
-
|
|
18
|
-
RSpec/ExampleLength:
|
|
19
|
-
Max: 15
|
|
20
|
-
|
|
21
|
-
Metrics/ClassLength:
|
|
22
|
-
Max: 150
|
|
23
|
-
|
|
24
|
-
Metrics/MethodLength:
|
|
25
|
-
Max: 16
|
|
26
|
-
|
|
27
|
-
Metrics/ParameterLists:
|
|
28
|
-
MaxOptionalParameters: 6
|
|
29
|
-
CountKeywordArgs: false
|
|
30
|
-
|
|
31
|
-
Style/Documentation:
|
|
32
|
-
Enabled: false
|
|
33
|
-
|
|
34
|
-
Layout/LineLength:
|
|
35
|
-
Max: 120
|
|
36
|
-
|
|
37
|
-
Style/StringLiterals:
|
|
38
|
-
Enabled: true
|
|
39
|
-
EnforcedStyle: double_quotes
|
|
40
|
-
|
|
41
|
-
Layout/MultilineMethodCallIndentation:
|
|
42
|
-
EnforcedStyle: indented
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
-
identity and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
-
community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
-
any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email address,
|
|
35
|
-
without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official email address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
[INSERT CONTACT METHOD].
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series of
|
|
86
|
-
actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
-
ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
-
community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.1, available at
|
|
119
|
-
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by
|
|
122
|
-
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
-
|
|
124
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
-
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
-
|
|
128
|
-
[homepage]: https://www.contributor-covenant.org
|
|
129
|
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
-
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
-
[translations]: https://www.contributor-covenant.org/translations
|
data/CONTRIBUTING.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
Thanks for wanting to contribute to Docyard!
|
|
4
|
-
|
|
5
|
-
## Development Setup
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
git clone https://github.com/YOUR_USERNAME/docyard.git
|
|
9
|
-
cd docyard
|
|
10
|
-
bundle install
|
|
11
|
-
|
|
12
|
-
# Run tests
|
|
13
|
-
bundle exec rspec
|
|
14
|
-
bundle exec rubocop
|
|
15
|
-
|
|
16
|
-
# Test locally
|
|
17
|
-
./bin/docyard init
|
|
18
|
-
./bin/docyard serve
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Pull Requests
|
|
22
|
-
|
|
23
|
-
1. Fork the repo and create a branch from `main`
|
|
24
|
-
2. Write tests for new features
|
|
25
|
-
3. Run `bundle exec rspec && bundle exec rubocop`
|
|
26
|
-
4. Update README/CHANGELOG if needed
|
|
27
|
-
5. Use conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `test:`
|
|
28
|
-
|
|
29
|
-
## Architecture
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
lib/docyard/
|
|
33
|
-
cli.rb # CLI
|
|
34
|
-
server.rb # Server lifecycle
|
|
35
|
-
rack_application.rb # HTTP handling
|
|
36
|
-
router.rb # URL → file mapping
|
|
37
|
-
renderer.rb # Markdown → HTML
|
|
38
|
-
markdown.rb # Parsing
|
|
39
|
-
file_watcher.rb # Live reload
|
|
40
|
-
asset_handler.rb # Static assets
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Code Style
|
|
44
|
-
|
|
45
|
-
- Maintain >85% test coverage
|
|
46
|
-
- Keep methods focused and readable
|
|
47
|
-
- Add tests for new features
|
|
48
|
-
|
|
49
|
-
## Questions?
|
|
50
|
-
|
|
51
|
-
Open an issue.
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
Thanks for contributing! 🚀
|
data/LICENSE.vscode-icons
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
File Type Icons from VSCode Icons
|
|
2
|
-
=====================================
|
|
3
|
-
|
|
4
|
-
The file type icons embedded in lib/docyard/icons/file_types.rb are from the VSCode Icons project:
|
|
5
|
-
https://github.com/vscode-icons/vscode-icons
|
|
6
|
-
|
|
7
|
-
License: Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
|
8
|
-
https://creativecommons.org/licenses/by-sa/4.0/
|
|
9
|
-
|
|
10
|
-
Copyright (c) 2016 Roberto Huertas
|
|
11
|
-
|
|
12
|
-
Icons included:
|
|
13
|
-
- JavaScript (.js)
|
|
14
|
-
- TypeScript (.ts)
|
|
15
|
-
- JSX (.jsx)
|
|
16
|
-
- TSX (.tsx)
|
|
17
|
-
- Python (.py)
|
|
18
|
-
- Ruby (.rb)
|
|
19
|
-
- HTML (.html)
|
|
20
|
-
- CSS (.css)
|
|
21
|
-
- JSON (.json)
|
|
22
|
-
- YAML (.yaml)
|
|
23
|
-
- TOML (.toml)
|
|
24
|
-
- Go (.go)
|
|
25
|
-
- Rust (.rs)
|
|
26
|
-
- PHP (.php)
|
|
27
|
-
- SQL (.sql)
|
|
28
|
-
- MySQL (.mysql)
|
|
29
|
-
- PostgreSQL (.pgsql)
|
|
30
|
-
- GraphQL (.graphql)
|
|
31
|
-
- Vue (.vue)
|
|
32
|
-
- Svelte (.svelte)
|
|
33
|
-
- Protobuf (.proto)
|
|
34
|
-
|
|
35
|
-
These icons are used under the terms of the CC BY-SA 4.0 license.
|
|
36
|
-
You are free to:
|
|
37
|
-
- Share — copy and redistribute the material in any medium or format
|
|
38
|
-
- Adapt — remix, transform, and build upon the material for any purpose, even commercially
|
|
39
|
-
|
|
40
|
-
Under the following terms:
|
|
41
|
-
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made
|
|
42
|
-
- ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license
|
data/Rakefile
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Docyard
|
|
4
|
-
module Constants
|
|
5
|
-
CONTENT_TYPE_HTML = "text/html; charset=utf-8"
|
|
6
|
-
CONTENT_TYPE_JSON = "application/json; charset=utf-8"
|
|
7
|
-
CONTENT_TYPE_CSS = "text/css; charset=utf-8"
|
|
8
|
-
CONTENT_TYPE_JS = "application/javascript; charset=utf-8"
|
|
9
|
-
|
|
10
|
-
RELOAD_ENDPOINT = "/_docyard/reload"
|
|
11
|
-
DOCYARD_ASSETS_PREFIX = "/_docyard/"
|
|
12
|
-
PAGEFIND_PREFIX = "/pagefind/"
|
|
13
|
-
PUBLIC_DIR = "docs/public"
|
|
14
|
-
|
|
15
|
-
INDEX_FILE = "index"
|
|
16
|
-
INDEX_TITLE = "Home"
|
|
17
|
-
|
|
18
|
-
MARKDOWN_EXTENSION = ".md"
|
|
19
|
-
HTML_EXTENSION = ".html"
|
|
20
|
-
|
|
21
|
-
STATUS_OK = 200
|
|
22
|
-
STATUS_REDIRECT = 302
|
|
23
|
-
STATUS_NOT_FOUND = 404
|
|
24
|
-
STATUS_INTERNAL_ERROR = 500
|
|
25
|
-
|
|
26
|
-
DEFAULT_SITE_TITLE = "Documentation"
|
|
27
|
-
DEFAULT_LOGO_PATH = "_docyard/logo.svg"
|
|
28
|
-
DEFAULT_LOGO_DARK_PATH = "_docyard/logo-dark.svg"
|
|
29
|
-
DEFAULT_FAVICON_PATH = "_docyard/favicon.svg"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Docyard
|
|
4
|
-
module Sidebar
|
|
5
|
-
class ChildrenDiscoverer
|
|
6
|
-
attr_reader :docs_path
|
|
7
|
-
|
|
8
|
-
def initialize(docs_path:)
|
|
9
|
-
@docs_path = docs_path
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def discover(relative_path, depth:, &item_builder)
|
|
13
|
-
full_path = File.join(docs_path, relative_path)
|
|
14
|
-
return [] unless File.directory?(full_path)
|
|
15
|
-
|
|
16
|
-
local_config = load_local_sidebar_config(full_path)
|
|
17
|
-
return yield(local_config, relative_path, depth) if local_config
|
|
18
|
-
|
|
19
|
-
discover_from_filesystem(full_path, relative_path, depth, &item_builder)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def load_local_sidebar_config(dir_path)
|
|
25
|
-
LocalConfigLoader.new(dir_path).load
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def discover_from_filesystem(full_path, relative_path, depth, &item_builder)
|
|
29
|
-
entries = filtered_entries(full_path)
|
|
30
|
-
entries.map { |entry| build_entry(entry, full_path, relative_path, depth, &item_builder) }.compact
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def filtered_entries(full_path)
|
|
34
|
-
Dir.children(full_path)
|
|
35
|
-
.reject { |e| e.start_with?(".") || e.start_with?("_") || e == "index.md" }
|
|
36
|
-
.sort
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def build_entry(entry, full_path, relative_path, depth)
|
|
40
|
-
entry_path = File.join(full_path, entry)
|
|
41
|
-
|
|
42
|
-
if File.directory?(entry_path)
|
|
43
|
-
yield(:directory, entry, relative_path, depth)
|
|
44
|
-
elsif entry.end_with?(".md")
|
|
45
|
-
slug = entry.delete_suffix(".md")
|
|
46
|
-
yield(:file, slug, relative_path, depth)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "item"
|
|
4
|
-
require_relative "title_extractor"
|
|
5
|
-
require_relative "metadata_extractor"
|
|
6
|
-
require_relative "children_discoverer"
|
|
7
|
-
require_relative "file_resolver"
|
|
8
|
-
|
|
9
|
-
module Docyard
|
|
10
|
-
module Sidebar
|
|
11
|
-
class ConfigParser # rubocop:disable Metrics/ClassLength
|
|
12
|
-
attr_reader :config_items, :docs_path, :current_path, :metadata_extractor,
|
|
13
|
-
:children_discoverer, :file_resolver
|
|
14
|
-
|
|
15
|
-
def initialize(config_items, docs_path:, current_path: "/", title_extractor: TitleExtractor.new)
|
|
16
|
-
@config_items = config_items || []
|
|
17
|
-
@docs_path = docs_path
|
|
18
|
-
@current_path = Utils::PathResolver.normalize(current_path)
|
|
19
|
-
@metadata_extractor = MetadataExtractor.new(docs_path: docs_path, title_extractor: title_extractor)
|
|
20
|
-
@children_discoverer = ChildrenDiscoverer.new(docs_path: docs_path)
|
|
21
|
-
@file_resolver = FileResolver.new(
|
|
22
|
-
docs_path: docs_path, current_path: @current_path, metadata_extractor: metadata_extractor
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def parse
|
|
27
|
-
parse_items(config_items, "", depth: 1)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
def parse_items(items, base_path, depth:)
|
|
33
|
-
items.map { |item_config| parse_item(item_config, base_path, depth: depth) }.compact
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def parse_item(item_config, base_path, depth:)
|
|
37
|
-
case item_config
|
|
38
|
-
when String then resolve_string_item(item_config, base_path, depth: depth)
|
|
39
|
-
when Hash then parse_hash_item(item_config, base_path, depth: depth)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def resolve_string_item(slug, base_path, depth:)
|
|
44
|
-
if File.directory?(File.join(docs_path, base_path, slug))
|
|
45
|
-
build_directory_item(slug, {}, [], base_path, depth: depth)
|
|
46
|
-
else
|
|
47
|
-
file_resolver.resolve(slug, base_path)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def parse_hash_item(item_config, base_path, depth:)
|
|
52
|
-
return file_resolver.build_link_item(item_config) if external_link?(item_config)
|
|
53
|
-
|
|
54
|
-
slug = item_config.keys.first
|
|
55
|
-
options = item_config.values.first
|
|
56
|
-
|
|
57
|
-
return file_resolver.resolve(slug, base_path, {}) if options.nil?
|
|
58
|
-
return parse_nested_item(slug, options, base_path, depth: depth) if options.is_a?(Hash)
|
|
59
|
-
|
|
60
|
-
file_resolver.resolve(slug, base_path, options)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def external_link?(config)
|
|
64
|
-
config.key?("link") || config.key?(:link)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
68
|
-
def parse_nested_item(slug, options, base_path, depth:)
|
|
69
|
-
slug = slug.to_s
|
|
70
|
-
nested_items = options["items"] || options[:items] || []
|
|
71
|
-
dir_path = File.join(docs_path, base_path, slug)
|
|
72
|
-
is_virtual_group = (options["section"] == false || options[:section] == false) && nested_items.any?
|
|
73
|
-
|
|
74
|
-
if is_virtual_group
|
|
75
|
-
build_virtual_group_item(slug, options, nested_items, base_path, depth: depth)
|
|
76
|
-
elsif File.directory?(dir_path)
|
|
77
|
-
build_directory_item(slug, options, nested_items, base_path, depth: depth)
|
|
78
|
-
elsif nested_items.any?
|
|
79
|
-
build_file_with_children_item(slug, options, nested_items, base_path, depth: depth)
|
|
80
|
-
else
|
|
81
|
-
file_resolver.resolve(slug, base_path, options)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
85
|
-
|
|
86
|
-
def build_virtual_group_item(slug, options, nested_items, base_path, depth:)
|
|
87
|
-
common_opts = metadata_extractor.extract_common_options(options)
|
|
88
|
-
parsed_items = parse_items(nested_items, base_path, depth: depth + 1)
|
|
89
|
-
is_collapsed = common_opts[:collapsed] != false && !active_child?(parsed_items)
|
|
90
|
-
|
|
91
|
-
Item.new(
|
|
92
|
-
slug: slug,
|
|
93
|
-
text: common_opts[:text] || Utils::TextFormatter.titleize(slug),
|
|
94
|
-
path: nil,
|
|
95
|
-
icon: common_opts[:icon],
|
|
96
|
-
collapsed: is_collapsed,
|
|
97
|
-
active: false,
|
|
98
|
-
items: parsed_items,
|
|
99
|
-
type: :directory,
|
|
100
|
-
section: false
|
|
101
|
-
)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def build_directory_item(slug, options, nested_items, base_path, depth:)
|
|
105
|
-
context = build_directory_context(slug, options, nested_items, base_path, depth)
|
|
106
|
-
context[:parsed_items] = prepend_intro_if_needed(context, depth)
|
|
107
|
-
create_directory_item(slug, context, depth)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def build_directory_context(slug, options, nested_items, base_path, depth)
|
|
111
|
-
new_base_path = File.join(base_path, slug)
|
|
112
|
-
{
|
|
113
|
-
common_opts: metadata_extractor.extract_common_options(options),
|
|
114
|
-
parsed_items: resolve_directory_children(nested_items, new_base_path, depth),
|
|
115
|
-
**build_index_info(new_base_path)
|
|
116
|
-
}
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def build_index_info(base_path)
|
|
120
|
-
index_file_path = File.join(docs_path, base_path, "index.md")
|
|
121
|
-
has_index = File.file?(index_file_path)
|
|
122
|
-
url_path = has_index ? Utils::PathResolver.to_url(base_path) : nil
|
|
123
|
-
|
|
124
|
-
{ index_file_path: index_file_path, has_index: has_index,
|
|
125
|
-
url_path: url_path, is_active: has_index && current_path == url_path }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def resolve_directory_children(nested_items, base_path, depth)
|
|
129
|
-
return parse_items(nested_items, base_path, depth: depth + 1) if nested_items.any?
|
|
130
|
-
|
|
131
|
-
auto_discover_children(base_path, depth: depth + 1)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def prepend_intro_if_needed(context, depth)
|
|
135
|
-
is_section = section_for_depth?(context[:common_opts][:section], depth)
|
|
136
|
-
return context[:parsed_items] unless is_section && context[:has_index]
|
|
137
|
-
|
|
138
|
-
[build_introduction_item(context[:index_file_path], context[:url_path])] + context[:parsed_items]
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def create_directory_item(slug, context, depth)
|
|
142
|
-
is_section = section_for_depth?(context[:common_opts][:section], depth)
|
|
143
|
-
Item.new(
|
|
144
|
-
slug: slug,
|
|
145
|
-
text: context[:common_opts][:text] || Utils::TextFormatter.titleize(slug),
|
|
146
|
-
path: is_section ? nil : context[:url_path],
|
|
147
|
-
icon: context[:common_opts][:icon],
|
|
148
|
-
collapsed: is_section ? false : directory_collapsed?(context),
|
|
149
|
-
active: is_section ? false : context[:is_active],
|
|
150
|
-
has_index: is_section ? false : context[:has_index],
|
|
151
|
-
items: context[:parsed_items],
|
|
152
|
-
type: :directory,
|
|
153
|
-
section: is_section
|
|
154
|
-
)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def section_for_depth?(explicit_section, depth)
|
|
158
|
-
return explicit_section unless explicit_section.nil?
|
|
159
|
-
|
|
160
|
-
depth == 1
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def directory_collapsed?(context)
|
|
164
|
-
return false if context[:is_active] || active_child?(context[:parsed_items])
|
|
165
|
-
|
|
166
|
-
context[:common_opts][:collapsed] != false
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def build_introduction_item(index_file_path, url_path)
|
|
170
|
-
metadata = metadata_extractor.extract_index_metadata(index_file_path)
|
|
171
|
-
Item.new(
|
|
172
|
-
slug: "index", text: metadata[:sidebar_text] || "Overview",
|
|
173
|
-
path: url_path, icon: metadata[:icon], active: current_path == url_path, type: :file
|
|
174
|
-
)
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def build_file_with_children_item(slug, options, nested_items, base_path, depth:)
|
|
178
|
-
file_resolver.build_file_with_children(
|
|
179
|
-
slug: slug, options: options, base_path: base_path,
|
|
180
|
-
parsed_items: parse_items(nested_items, base_path, depth: depth + 1),
|
|
181
|
-
depth: depth
|
|
182
|
-
)
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def auto_discover_children(relative_path, depth:)
|
|
186
|
-
children_discoverer.discover(relative_path, depth: depth) do |config_or_type, *args|
|
|
187
|
-
if config_or_type.is_a?(Array)
|
|
188
|
-
parse_items(config_or_type, args[0], depth: args[1])
|
|
189
|
-
else
|
|
190
|
-
build_discovered_item(config_or_type, args[0], args[1], depth)
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def build_discovered_item(type, slug, base_path, depth)
|
|
196
|
-
if type == :directory
|
|
197
|
-
build_directory_item(slug, {}, [], base_path, depth: depth)
|
|
198
|
-
else
|
|
199
|
-
file_resolver.resolve(slug, base_path)
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
def active_child?(items)
|
|
204
|
-
items.any? { |item| item.active || active_child?(item.items) }
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|