doc_pages 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +8 -0
- data/app/assets/config/doc_pages_manifest.js +1 -0
- data/app/assets/stylesheets/doc_pages/application.css +15 -0
- data/app/controllers/doc_pages/application_controller.rb +4 -0
- data/app/controllers/doc_pages/docs_controller.rb +7 -0
- data/app/helpers/doc_pages/application_helper.rb +42 -0
- data/app/jobs/doc_pages/application_job.rb +4 -0
- data/app/mailers/doc_pages/application_mailer.rb +6 -0
- data/app/models/doc_pages/application_record.rb +5 -0
- data/app/views/layouts/doc_pages/application.html.erb +15 -0
- data/app/views/layouts/doc_pages/markdown.html.erb +25 -0
- data/app/views/shared/_desktop_sidebar.html.erb +36 -0
- data/app/views/shared/_mobile_sidebar.html.erb +79 -0
- data/app/views/shared/_pages.html.erb +4 -0
- data/app/views/shared/_sidebar.html.erb +53 -0
- data/app/views/shared/_tailwind.html.erb +13 -0
- data/config/initializers/doc_pages.rb +12 -0
- data/config/routes.rb +5 -0
- data/lib/doc_pages/engine.rb +13 -0
- data/lib/doc_pages/version.rb +3 -0
- data/lib/doc_pages.rb +6 -0
- data/lib/generators/docs/USAGE +8 -0
- data/lib/generators/docs/docs_generator.rb +44 -0
- data/lib/generators/docs/templates/home.html.md +36 -0
- data/lib/handlers/markdown_handler.rb +27 -0
- data/lib/tasks/doc_pages_tasks.rake +4 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e258e0c9c9f4a6b099e505aa7b9330c518d1cae29f1ced3b60432f11a22251da
|
4
|
+
data.tar.gz: 02d19f8dcc46afa96ff8c8eec6ded93b31c05580d7ba2edf5a0aa7ced1d6a685
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a1a42572fd4fde86c649c2c0c6e81f4c5c781e49849dcb7fb554551ccede798a5b5ec77f3b13e1e36bcad406a957f9b6251d81c67c928b65f3e13c1e5465264
|
7
|
+
data.tar.gz: ef38951574662db55020dfc601c8dd9dc4c6d12385c05d2c6ba94689785d3c1ea2ca27238532797f2896b0dc0e0253d620f61e682e8ad34b54a2d5384faabbf6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2023 lbp
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# DocPages
|
2
|
+
DocPages is a Rails engine that provides a simple way to add documentation to your Rails application using Markdown. Create your documentation files in the `app/views/docs` directory with the `.html.md` extension and navigate to `/docs` to see it in action. Code snippets are syntax highlighted using Highlight.js.
|
3
|
+
|
4
|
+
## Table of Contents
|
5
|
+
- [DocPages](#docpages)
|
6
|
+
- [Table of Contents](#table-of-contents)
|
7
|
+
- [Installation](#installation)
|
8
|
+
- [Getting Started](#getting-started)
|
9
|
+
- [Adding Pages](#adding-pages)
|
10
|
+
- [Customizing the views](#customizing-the-views)
|
11
|
+
- [Contributing](#contributing)
|
12
|
+
- [License](#license)
|
13
|
+
|
14
|
+
## <span id="installation">Installation</span>
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem "doc_pages"
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
```bash
|
23
|
+
$ bundle
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
```bash
|
28
|
+
$ gem install doc_pages
|
29
|
+
```
|
30
|
+
## <span id="getting-started">Getting Started</span>
|
31
|
+
- Run `rails g doc_pages install`
|
32
|
+
|
33
|
+
## <span id="adding-pages">Adding Pages</span>
|
34
|
+
|
35
|
+
- To add a new page, create a new file in the `app/views/docs` directory. The file name will be the URL path for the page. For example, `app/views/docs/my-new-page.html.md` will be available at `/docs/my-new-page`.
|
36
|
+
|
37
|
+
## <span id="customizing-the-views">Customizing the views</span>
|
38
|
+
|
39
|
+
- To customize the views, run `rails g docs copy_views`.
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
Issues and pull requests are welcome on GitHub at https://github.com/leopolicastro/doc_pages.
|
43
|
+
|
44
|
+
## License
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/doc_pages .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module DocPages
|
2
|
+
module ApplicationHelper
|
3
|
+
def doc_page_ids
|
4
|
+
HighVoltage.page_ids - ["home"]
|
5
|
+
end
|
6
|
+
|
7
|
+
def group_by_folder
|
8
|
+
doc_page_ids.filter { |id| id.include?("/") }.group_by { |id| id.split("/").first }
|
9
|
+
end
|
10
|
+
|
11
|
+
def without_a_folder
|
12
|
+
doc_page_ids.reject { |id| id.include?("/") }
|
13
|
+
end
|
14
|
+
|
15
|
+
def render_orphans
|
16
|
+
without_a_folder.map { |page| link_to_page(page) }.join("").html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
def group_by_folder_and_render
|
20
|
+
group_by_folder.map do |folder, pages|
|
21
|
+
<<-ERB
|
22
|
+
<div class="flex flex-col gap-y-2 mb-5">
|
23
|
+
<h2 class="text-white font-semibold text-lg hover:cursor-pointer js-folders">#{folder.titleize}</h2>
|
24
|
+
<ul class="flex flex-col gap-y-2 hidden js-toggle-hidden">
|
25
|
+
#{pages.map { |page| link_to_page(page) }.join("").html_safe}
|
26
|
+
</ul>
|
27
|
+
<div class="border-b"></div>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
ERB
|
31
|
+
end.join("").html_safe
|
32
|
+
end
|
33
|
+
|
34
|
+
def link_to_page(page)
|
35
|
+
<<-ERB
|
36
|
+
<li>
|
37
|
+
#{link_to page.split("/").last.titleize, doc_path(page), data: {turbo: false}, class: "text-white group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold"}
|
38
|
+
</li>
|
39
|
+
ERB
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= yield(:page_title) %></title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
|
9
|
+
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
10
|
+
<%= javascript_importmap_tags %>
|
11
|
+
<%= render "shared/tailwind" %>
|
12
|
+
<link rel="stylesheet"
|
13
|
+
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark-dimmed.min.css">
|
14
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
15
|
+
<script>
|
16
|
+
hljs.highlightAll();
|
17
|
+
</script>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<%= render "shared/sidebar" %>
|
21
|
+
<main class="prose prose-blue 2xl:prose-xl container mx-auto px-5 md:ml-80">
|
22
|
+
<%= yield %>
|
23
|
+
</main>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!-- Static sidebar for desktop -->
|
2
|
+
<div class="hidden md:fixed md:inset-y-0 md:z-50 md:flex md:w-72 md:flex-col">
|
3
|
+
<!-- Sidebar component, swap this element with another sidebar if you like -->
|
4
|
+
<div class="flex grow flex-col gap-y-5 overflow-y-auto bg-gray-900 px-6">
|
5
|
+
<div class="flex h-16 shrink-0 items-center">
|
6
|
+
<h2 class="text-2xl text-white">DocPages</h2>
|
7
|
+
</div>
|
8
|
+
<nav class="flex flex-1 flex-col">
|
9
|
+
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
10
|
+
<li>
|
11
|
+
<ul role="list" class="-mx-2 space-y-1">
|
12
|
+
<li>
|
13
|
+
<!-- Current: "bg-gray-800 text-white", Default: "text-gray-400 hover:text-white hover:bg-gray-800" -->
|
14
|
+
<%= link_to doc_pages_root_path, data: {turbo: false}, class: "bg-gray-800 text-white group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold" do %>
|
15
|
+
<svg class="h-6 w-6 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
16
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
17
|
+
</svg>
|
18
|
+
Home
|
19
|
+
<% end %>
|
20
|
+
</li>
|
21
|
+
<%= render "shared/pages" %>
|
22
|
+
</ul>
|
23
|
+
</li>
|
24
|
+
<%# <li class="mt-auto mb-5">
|
25
|
+
<a href="#" class="group -mx-2 flex gap-x-3 rounded-md p-2 text-sm font-semibold leading-6 text-gray-400 hover:bg-gray-800 hover:text-white">
|
26
|
+
<svg class="h-6 w-6 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
27
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z" />
|
28
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
29
|
+
</svg>
|
30
|
+
Settings
|
31
|
+
</a>
|
32
|
+
</li> %>
|
33
|
+
</ul>
|
34
|
+
</nav>
|
35
|
+
</div>
|
36
|
+
</div>
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<!-- Off-canvas menu for mobile, show/hide based on off-canvas menu state. -->
|
2
|
+
<div class="relative z-50 hidden" role="dialog" aria-modal="true" id="mobile-sidebar">
|
3
|
+
<!--
|
4
|
+
Off-canvas menu backdrop, show/hide based on off-canvas menu state.
|
5
|
+
|
6
|
+
Entering: "transition-opacity ease-linear duration-300"
|
7
|
+
From: "opacity-0"
|
8
|
+
To: "opacity-100"
|
9
|
+
Leaving: "transition-opacity ease-linear duration-300"
|
10
|
+
From: "opacity-100"
|
11
|
+
To: "opacity-0"
|
12
|
+
-->
|
13
|
+
<div class="fixed inset-0 bg-gray-900/80"></div>
|
14
|
+
<div class="fixed inset-0 flex">
|
15
|
+
<!--
|
16
|
+
Off-canvas menu, show/hide based on off-canvas menu state.
|
17
|
+
|
18
|
+
Entering: "transition ease-in-out duration-300 transform"
|
19
|
+
From: "-translate-x-full"
|
20
|
+
To: "translate-x-0"
|
21
|
+
Leaving: "transition ease-in-out duration-300 transform"
|
22
|
+
From: "translate-x-0"
|
23
|
+
To: "-translate-x-full"
|
24
|
+
-->
|
25
|
+
<div class="relative mr-16 flex w-full max-w-xs flex-1">
|
26
|
+
<!--
|
27
|
+
Close button, show/hide based on off-canvas menu state.
|
28
|
+
|
29
|
+
Entering: "ease-in-out duration-300"
|
30
|
+
From: "opacity-0"
|
31
|
+
To: "opacity-100"
|
32
|
+
Leaving: "ease-in-out duration-300"
|
33
|
+
From: "opacity-100"
|
34
|
+
To: "opacity-0"
|
35
|
+
-->
|
36
|
+
<div class="absolute left-full top-0 flex w-16 justify-center pt-5">
|
37
|
+
<button type="button" class="-m-2.5 p-2.5" id="close-sidebar">
|
38
|
+
<span class="sr-only">Close sidebar</span>
|
39
|
+
<svg class="h-6 w-6 text-white" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
40
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
41
|
+
</svg>
|
42
|
+
</button>
|
43
|
+
</div>
|
44
|
+
<!-- Sidebar component, swap this element with another sidebar if you like -->
|
45
|
+
<div class="flex grow flex-col gap-y-5 overflow-y-auto bg-gray-900 px-6 pb-2 ring-1 ring-white/10">
|
46
|
+
<div class="flex h-16 shrink-0 items-center">
|
47
|
+
<h2 class="text-2xl text-white">Docs</h2>
|
48
|
+
</div>
|
49
|
+
<nav class="flex flex-1 flex-col">
|
50
|
+
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
51
|
+
<li>
|
52
|
+
<ul role="list" class="-mx-2 space-y-1">
|
53
|
+
<li class="">
|
54
|
+
<!-- Current: "bg-gray-800 text-white", Default: "text-gray-400 hover:text-white hover:bg-gray-800" -->
|
55
|
+
<%= link_to doc_pages_root_path, class: "bg-gray-800 text-white group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold" do %>
|
56
|
+
<svg class="h-6 w-6 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
57
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
58
|
+
</svg>
|
59
|
+
Home
|
60
|
+
<% end %>
|
61
|
+
</li>
|
62
|
+
<%= render "shared/pages" %>
|
63
|
+
</ul>
|
64
|
+
</li>
|
65
|
+
<%# <li class="mt-auto mb-5">
|
66
|
+
<a href="#" class="group -mx-2 flex gap-x-3 rounded-md p-2 text-sm font-semibold leading-6 text-gray-400 hover:bg-gray-800 hover:text-white">
|
67
|
+
<svg class="h-6 w-6 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
68
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z" />
|
69
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
70
|
+
</svg>
|
71
|
+
Settings
|
72
|
+
</a>
|
73
|
+
</li> %>
|
74
|
+
</ul>
|
75
|
+
</nav>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
</div>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<!--
|
2
|
+
This example requires updating your template:
|
3
|
+
|
4
|
+
```
|
5
|
+
<html class="h-full bg-white">
|
6
|
+
<body class="h-full">
|
7
|
+
```
|
8
|
+
-->
|
9
|
+
<div>
|
10
|
+
<%= render "shared/mobile_sidebar" %>
|
11
|
+
<%= render "shared/desktop_sidebar" %>
|
12
|
+
<div class="sticky top-0 z-40 flex items-center gap-x-6 bg-gray-900 px-4 py-4 shadow-sm sm:px-6 lg:hidden">
|
13
|
+
<button type="button" class="-m-2.5 p-2.5 text-gray-400 lg:hidden" id="open-sidebar">
|
14
|
+
<span class="sr-only">Open sidebar</span>
|
15
|
+
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
|
16
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
|
17
|
+
</svg>
|
18
|
+
</button>
|
19
|
+
<div class="flex-1 text-sm font-semibold leading-6 text-white">Dashboard</div>
|
20
|
+
<a href="#">
|
21
|
+
<span class="sr-only">Your profile</span>
|
22
|
+
<img class="h-8 w-8 rounded-full bg-gray-800" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
|
23
|
+
</a>
|
24
|
+
</div>
|
25
|
+
<main class="py-10 lg:pl-72">
|
26
|
+
<div class="px-4 sm:px-6 lg:px-8">
|
27
|
+
<!-- Your content -->
|
28
|
+
</div>
|
29
|
+
</main>
|
30
|
+
</div>
|
31
|
+
<script>
|
32
|
+
var mobileSidebar = document.getElementById('mobile-sidebar');
|
33
|
+
var closeSidebarButton = document.getElementById('close-sidebar');
|
34
|
+
|
35
|
+
closeSidebarButton.addEventListener('click', () => {
|
36
|
+
mobileSidebar.classList.add('hidden');
|
37
|
+
});
|
38
|
+
|
39
|
+
|
40
|
+
var openSidebarButton = document.getElementById('open-sidebar');
|
41
|
+
|
42
|
+
openSidebarButton.addEventListener('click', () => {
|
43
|
+
mobileSidebar.classList.remove('hidden');
|
44
|
+
});
|
45
|
+
|
46
|
+
document.querySelectorAll(".js-folders").forEach((el) => {
|
47
|
+
el.addEventListener("click", (e) => {
|
48
|
+
e.preventDefault();
|
49
|
+
|
50
|
+
el.nextElementSibling.classList.toggle("hidden");
|
51
|
+
});
|
52
|
+
});
|
53
|
+
</script>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
|
2
|
+
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
|
3
|
+
<script>
|
4
|
+
tailwind.config = {
|
5
|
+
theme: {
|
6
|
+
extend: {
|
7
|
+
fontFamily: {
|
8
|
+
sans: ['Inter var'],
|
9
|
+
},
|
10
|
+
},
|
11
|
+
}
|
12
|
+
}
|
13
|
+
</script>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "handlers/markdown_handler"
|
2
|
+
|
3
|
+
HighVoltage.configure do |config|
|
4
|
+
config.routes = false
|
5
|
+
config.content_path = "docs/"
|
6
|
+
# config.home_page = "home"
|
7
|
+
end
|
8
|
+
|
9
|
+
ActionView::Template.register_template_handler(
|
10
|
+
:md,
|
11
|
+
Handlers::MarkdownHandler.new
|
12
|
+
)
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "high_voltage"
|
2
|
+
require "redcarpet"
|
3
|
+
|
4
|
+
module DocPages
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
isolate_namespace DocPages
|
7
|
+
|
8
|
+
initializer "engine_name.assets.precompile" do |app|
|
9
|
+
# app.config.assets.precompile += %w[docs_manifest.js]
|
10
|
+
app.config.assets.precompile += %w[config/doc_pages_manifest.js]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/doc_pages.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class DocsGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path("templates", __dir__)
|
3
|
+
|
4
|
+
def handle_call
|
5
|
+
if ARGV[0] == "install"
|
6
|
+
install
|
7
|
+
elsif ARGV[0] == "copy_views"
|
8
|
+
copy_views
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def copy_views
|
15
|
+
copy_file File.expand_path("#{DocPages::Engine.root}/app/views/shared/_sidebar.html.erb"), "app/views/shared/_sidebar.html.erb"
|
16
|
+
copy_file File.expand_path("#{DocPages::Engine.root}/app/views/shared/_desktop_sidebar.html.erb"), "app/views/shared/_desktop_sidebar.html.erb"
|
17
|
+
copy_file File.expand_path("#{DocPages::Engine.root}/app/views/shared/_mobile_sidebar.html.erb"), "app/views/shared/_mobile_sidebar.html.erb"
|
18
|
+
copy_file File.expand_path("#{DocPages::Engine.root}/app/views/shared/_pages.html.erb"), "app/views/shared/_pages.html.erb"
|
19
|
+
copy_file File.expand_path("#{DocPages::Engine.root}/app/views/layouts/doc_pages/markdown.html.erb"), "app/views/layouts/markdown.html.erb"
|
20
|
+
end
|
21
|
+
|
22
|
+
def install
|
23
|
+
mount_engine
|
24
|
+
copy_home_page
|
25
|
+
append_to_manifest
|
26
|
+
end
|
27
|
+
|
28
|
+
def mount_engine
|
29
|
+
puts "Mounting Docs::Engine at \"/docs\" in config/routes.rb"
|
30
|
+
route "mount DocPages::Engine, at: \"/docs\""
|
31
|
+
end
|
32
|
+
|
33
|
+
def copy_home_page
|
34
|
+
puts "Copying home page to app/views/docs/home.html.md"
|
35
|
+
copy_file "home.html.md", "app/views/docs/home.html.md"
|
36
|
+
end
|
37
|
+
|
38
|
+
def append_to_manifest
|
39
|
+
puts "Appending to app/assets/config/manifest.js"
|
40
|
+
append_to_file "app/assets/config/manifest.js" do
|
41
|
+
"//= link doc_pages/application.css\n"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Docs
|
2
|
+
|
3
|
+
- This is the home page for your docs. To edit this page, update your `app/views/docs/home.html.md` file.
|
4
|
+
- All standard Markdown features are supported.
|
5
|
+
|
6
|
+
---
|
7
|
+
|
8
|
+
## Table of Contents
|
9
|
+
- [Getting Started](#getting-started)
|
10
|
+
- [Adding Pages](#adding-pages)
|
11
|
+
- [Customizing the Sidebar](#customizing-the-sidebar)
|
12
|
+
- [Customize Syntax Highlighting Theme](#customize-syntax-highlighting-theme)
|
13
|
+
|
14
|
+
### <span id="getting-started">Getting Started</span>
|
15
|
+
|
16
|
+
- Add the following to your `Gemfile`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'doc_pages'
|
20
|
+
```
|
21
|
+
- Run `bundle install`
|
22
|
+
- Or install it yourself as:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ bundle add doc_pages
|
26
|
+
```
|
27
|
+
- Run `rails g doc_pages install`
|
28
|
+
|
29
|
+
|
30
|
+
### <span id="adding-pages">Adding Pages</span>
|
31
|
+
|
32
|
+
- To add a new page, create a new file in the `app/views/docs` directory. The file name will be the URL path for the page. For example, `app/views/docs/my-new-page.html.md` will be available at `/docs/my-new-page`.
|
33
|
+
|
34
|
+
### <span id="customizing-the-views">Customizing the views</span>
|
35
|
+
|
36
|
+
- To customize the views, run `rails g docs copy_views`.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Handlers
|
2
|
+
class MarkdownHandler
|
3
|
+
def call(template, source)
|
4
|
+
markdown = Redcarpet::Markdown.new(
|
5
|
+
Redcarpet::Render::HTML,
|
6
|
+
autolink: true,
|
7
|
+
tables: true,
|
8
|
+
fenced_code_blocks: true,
|
9
|
+
underline: true,
|
10
|
+
highlight: true,
|
11
|
+
quote: true,
|
12
|
+
footnotes: true,
|
13
|
+
no_styles: true,
|
14
|
+
hard_wrap: true,
|
15
|
+
prettify: true,
|
16
|
+
safe_links_only: true,
|
17
|
+
no_intra_emphasis: true,
|
18
|
+
strikethrough: true,
|
19
|
+
superscript: true,
|
20
|
+
lax_spacing: true,
|
21
|
+
space_after_headers: true
|
22
|
+
# disable_indented_code_blocks: true # ????
|
23
|
+
)
|
24
|
+
"#{markdown.render(source).inspect}.html_safe"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doc_pages
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lbp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redcarpet
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: high_voltage
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tailwindcss-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Description of Docs.
|
70
|
+
email:
|
71
|
+
- 43428385+leopolicastro@users.noreply.github.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/assets/config/doc_pages_manifest.js
|
80
|
+
- app/assets/stylesheets/doc_pages/application.css
|
81
|
+
- app/controllers/doc_pages/application_controller.rb
|
82
|
+
- app/controllers/doc_pages/docs_controller.rb
|
83
|
+
- app/helpers/doc_pages/application_helper.rb
|
84
|
+
- app/jobs/doc_pages/application_job.rb
|
85
|
+
- app/mailers/doc_pages/application_mailer.rb
|
86
|
+
- app/models/doc_pages/application_record.rb
|
87
|
+
- app/views/layouts/doc_pages/application.html.erb
|
88
|
+
- app/views/layouts/doc_pages/markdown.html.erb
|
89
|
+
- app/views/shared/_desktop_sidebar.html.erb
|
90
|
+
- app/views/shared/_mobile_sidebar.html.erb
|
91
|
+
- app/views/shared/_pages.html.erb
|
92
|
+
- app/views/shared/_sidebar.html.erb
|
93
|
+
- app/views/shared/_tailwind.html.erb
|
94
|
+
- config/initializers/doc_pages.rb
|
95
|
+
- config/routes.rb
|
96
|
+
- lib/doc_pages.rb
|
97
|
+
- lib/doc_pages/engine.rb
|
98
|
+
- lib/doc_pages/version.rb
|
99
|
+
- lib/generators/docs/USAGE
|
100
|
+
- lib/generators/docs/docs_generator.rb
|
101
|
+
- lib/generators/docs/templates/home.html.md
|
102
|
+
- lib/handlers/markdown_handler.rb
|
103
|
+
- lib/tasks/doc_pages_tasks.rake
|
104
|
+
homepage: https://github.com/leopolicastro/docs
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata:
|
108
|
+
homepage_uri: https://github.com/leopolicastro/docs
|
109
|
+
source_code_uri: https://github.com/leopolicastro/docs
|
110
|
+
changelog_uri: https://github.com/leopolicastro/docs/blob/main/CHANGELOG.md
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubygems_version: 3.4.13
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Summary of Docs.
|
130
|
+
test_files: []
|