rtfdoc 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/.gitignore +6 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/bin/rtfdoc +6 -0
- data/lib/rtfdoc.rb +354 -0
- data/lib/rtfdoc/cli.rb +18 -0
- data/lib/rtfdoc/generators/bootstrap.rb +42 -0
- data/lib/rtfdoc/templates/Gemfile.erb +5 -0
- data/lib/rtfdoc/templates/config.yml.erb +3 -0
- data/lib/rtfdoc/templates/gitignore +3 -0
- data/lib/rtfdoc/templates/package.json.erb +20 -0
- data/lib/rtfdoc/templates/webpack.config.js.erb +40 -0
- data/lib/rtfdoc/version.rb +3 -0
- data/rtfdoc.gemspec +47 -0
- data/src/attributes.erb +47 -0
- data/src/css/application.scss +529 -0
- data/src/index.html.erb +34 -0
- data/src/js/index.js +117 -0
- data/src/js/scroll.js +32 -0
- data/src/section.erb +21 -0
- metadata +167 -0
data/src/index.html.erb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html class="no-js" lang="">
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<title>RTFDoc</title>
|
7
|
+
<meta name="description" content="">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
|
+
</head>
|
10
|
+
<body data-theme="dark">
|
11
|
+
<div id="sidebar" class="sidebar">
|
12
|
+
<div class="sidebar-header">
|
13
|
+
<div class="sidebar-title">
|
14
|
+
odyssey <span class="api">api</span>
|
15
|
+
</div>
|
16
|
+
<div class="theme-switch-wrapper">
|
17
|
+
<div class="theme-switch">
|
18
|
+
<label class="theme-switch" for="checkbox">
|
19
|
+
<input type="checkbox" id="checkbox" checked="checked" />
|
20
|
+
<div class="slider round"></div>
|
21
|
+
</label>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<nav class="sidebar-nav" role="navigation">
|
26
|
+
<ul><%= @menu_content %></ul>
|
27
|
+
</nav>
|
28
|
+
</div>
|
29
|
+
<div id="content" class="content-area">
|
30
|
+
<div class="top-nav" style="height: 50px"></div>
|
31
|
+
<%= @content %>
|
32
|
+
</div>
|
33
|
+
</body>
|
34
|
+
</html>
|
data/src/js/index.js
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
import './scroll'
|
2
|
+
import '../css/application.scss'
|
3
|
+
|
4
|
+
/* Theme switch */
|
5
|
+
|
6
|
+
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
|
7
|
+
const body = document.querySelector('body');
|
8
|
+
|
9
|
+
function switchTheme(e) {
|
10
|
+
if (e.target.checked) {
|
11
|
+
body.setAttribute('data-theme', 'dark');
|
12
|
+
} else {
|
13
|
+
body.setAttribute('data-theme', 'light');
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
toggleSwitch.addEventListener('change', switchTheme, false);
|
18
|
+
|
19
|
+
/* Navbar links & expandable */
|
20
|
+
|
21
|
+
const navbarExpandables = document.querySelectorAll('a.expandable');
|
22
|
+
|
23
|
+
function expandItems(e) {
|
24
|
+
const target = e.currentTarget;
|
25
|
+
const parent = target.parentElement;
|
26
|
+
const oldExpanded = document.querySelector('li.expanded');
|
27
|
+
if (oldExpanded) {
|
28
|
+
oldExpanded.classList.remove('expanded');
|
29
|
+
}
|
30
|
+
|
31
|
+
const anchor = parent.dataset.anchor;
|
32
|
+
if (anchor) {
|
33
|
+
const button = document.querySelector(`div[data-resource="${anchor}"]`)
|
34
|
+
button.click()
|
35
|
+
}
|
36
|
+
|
37
|
+
parent.classList.add('expanded');
|
38
|
+
}
|
39
|
+
|
40
|
+
navbarExpandables.forEach(b => {
|
41
|
+
b.addEventListener('click', expandItems, false);
|
42
|
+
});
|
43
|
+
|
44
|
+
/* Nested links */
|
45
|
+
|
46
|
+
function expandParent(e) {
|
47
|
+
const target = e.currentTarget;
|
48
|
+
let parent = target.parentElement;
|
49
|
+
|
50
|
+
while (parent.dataset.anchor === undefined) {
|
51
|
+
parent = parent.parentElement;
|
52
|
+
}
|
53
|
+
|
54
|
+
const anchor = parent.dataset.anchor;
|
55
|
+
if (anchor) {
|
56
|
+
const button = document.querySelector(`div[data-resource="${anchor}"]`)
|
57
|
+
button.click()
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
document.querySelectorAll('nav ul ul a').forEach(a => a.addEventListener('click', expandParent, true));
|
62
|
+
|
63
|
+
/* Nested attributes */
|
64
|
+
|
65
|
+
function toggleChildList(e) {
|
66
|
+
const target = e.currentTarget;
|
67
|
+
const newContent = target.getAttribute('data-content');
|
68
|
+
|
69
|
+
// Retrieve the <span> containing the text
|
70
|
+
const textNode = target.lastElementChild
|
71
|
+
|
72
|
+
// Change button element
|
73
|
+
target.setAttribute('data-content', textNode.innerText);
|
74
|
+
textNode.innerText = newContent;
|
75
|
+
target.classList.toggle('child-revealed');
|
76
|
+
|
77
|
+
// Toggle child list
|
78
|
+
const list = target.nextElementSibling;
|
79
|
+
list.classList.toggle('hidden');
|
80
|
+
|
81
|
+
// Toggle list <div> as shown
|
82
|
+
const parent = target.parentElement;
|
83
|
+
parent.classList.toggle('list-shown');
|
84
|
+
}
|
85
|
+
|
86
|
+
const childListButtons = document.querySelectorAll('.section-list-title-child');
|
87
|
+
childListButtons.forEach(b => {
|
88
|
+
b.addEventListener('click', toggleChildList, true)
|
89
|
+
})
|
90
|
+
|
91
|
+
/** Show buttons **/
|
92
|
+
|
93
|
+
const showButtons = document.querySelectorAll('.button-wrapper');
|
94
|
+
|
95
|
+
function expandResource(e) {
|
96
|
+
const target = e.currentTarget;
|
97
|
+
const section = target.parentElement;
|
98
|
+
const headSection = section.parentElement;
|
99
|
+
const resource = target.dataset.resource;
|
100
|
+
|
101
|
+
if (resource) {
|
102
|
+
const anchor = document.querySelector(`nav li[data-anchor="${resource}"]`);
|
103
|
+
anchor.classList.add('expanded');
|
104
|
+
}
|
105
|
+
|
106
|
+
headSection.classList.add('expanded');
|
107
|
+
}
|
108
|
+
|
109
|
+
showButtons.forEach(b => b.addEventListener('click', expandResource, false));
|
110
|
+
|
111
|
+
window.onload = () => {
|
112
|
+
const hash = window.location.hash;
|
113
|
+
if (hash.includes('-')) {
|
114
|
+
const link = document.querySelector(`a[href="${hash}"]`);
|
115
|
+
if (link) link.click();
|
116
|
+
}
|
117
|
+
};
|
data/src/js/scroll.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
import throttle from 'lodash.throttle';
|
2
|
+
|
3
|
+
const sections = Array.prototype.slice.apply(
|
4
|
+
document.querySelectorAll('section')
|
5
|
+
).filter(s => s.id.length > 0).reverse()
|
6
|
+
|
7
|
+
const node = document.querySelector('#content');
|
8
|
+
|
9
|
+
let current = null,
|
10
|
+
currentLink = null;
|
11
|
+
|
12
|
+
function onScroll() {
|
13
|
+
const sectionOnScreen = sections.find(s => s.offsetTop > 0 && s.offsetTop <= node.scrollTop + 100);
|
14
|
+
|
15
|
+
if (sectionOnScreen.id !== current) {
|
16
|
+
if (currentLink) {
|
17
|
+
currentLink.classList.remove('current');
|
18
|
+
if (currentLink.classList.contains('expandable')) currentLink.parentElement.classList.remove('current');
|
19
|
+
}
|
20
|
+
|
21
|
+
const node = document.querySelector(`nav a[href="#${sectionOnScreen.id}"]`);
|
22
|
+
if (node) {
|
23
|
+
node.classList.add('current');
|
24
|
+
if (node.classList.contains('expandable')) node.parentElement.classList.add('current');
|
25
|
+
}
|
26
|
+
|
27
|
+
current = sectionOnScreen;
|
28
|
+
currentLink = node;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
node.addEventListener('scroll', throttle(onScroll, 400, { leading: true }), false);
|
data/src/section.erb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
<section id="<%= anchor_id %>">
|
2
|
+
<div class="section-divider"></div>
|
3
|
+
<div class="section-area">
|
4
|
+
<div class="section-body">
|
5
|
+
<%= content_to_html %>
|
6
|
+
</div>
|
7
|
+
<div class="section-example">
|
8
|
+
<%= example_to_html %>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
<% if include_show_button %>
|
12
|
+
<div class="button-wrapper" data-resource="<%= resource_name %>">
|
13
|
+
<div class="button">
|
14
|
+
<div>show</div>
|
15
|
+
<svg style="width: 12px;height: 12px;" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
16
|
+
<path d="M13.591 5.293a1 1 0 0 1 1.416 1.416l-6.3 6.3a1 1 0 0 1-1.414 0l-6.3-6.3A1 1 0 0 1 2.41 5.293L8 10.884z" fill-rule="evenodd"></path>
|
17
|
+
</svg>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
</section>
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rtfdoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ccocchi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: erubi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rouge
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.20.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.20.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redcarpet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.5.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.5.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.17'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.17'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- cocchi.c@gmail.com
|
114
|
+
executables:
|
115
|
+
- rtfdoc
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/rtfdoc
|
128
|
+
- lib/rtfdoc.rb
|
129
|
+
- lib/rtfdoc/cli.rb
|
130
|
+
- lib/rtfdoc/generators/bootstrap.rb
|
131
|
+
- lib/rtfdoc/templates/Gemfile.erb
|
132
|
+
- lib/rtfdoc/templates/config.yml.erb
|
133
|
+
- lib/rtfdoc/templates/gitignore
|
134
|
+
- lib/rtfdoc/templates/package.json.erb
|
135
|
+
- lib/rtfdoc/templates/webpack.config.js.erb
|
136
|
+
- lib/rtfdoc/version.rb
|
137
|
+
- rtfdoc.gemspec
|
138
|
+
- src/attributes.erb
|
139
|
+
- src/css/application.scss
|
140
|
+
- src/index.html.erb
|
141
|
+
- src/js/index.js
|
142
|
+
- src/js/scroll.js
|
143
|
+
- src/section.erb
|
144
|
+
homepage: https://github.com/ccocchi/rtfdoc
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubygems_version: 3.0.3
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Generate beautiful static documention for your APIs from markdown
|
167
|
+
test_files: []
|