pg-doc 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg/doc.rb +1 -0
- data/lib/pg/doc/engine.rb +11 -4
- data/lib/pg/doc/version.rb +1 -1
- data/static/pg-doc.js +7 -2
- data/views/includes/left_menu.erb +8 -1
- data/views/layout.erb +3 -0
- data/views/objects/function.erb +33 -1
- data/views/objects/table.erb +1 -1
- data/views/objects/trigger.erb +15 -0
- data/views/objects/view.erb +33 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edd4c08d6e5821b6faa98209653d65c20239881a
|
4
|
+
data.tar.gz: 8bcbf6a133bd04de380e7802c196ca65cf6b81d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5a640423d6e0f65b98f4fd375bb319f89781322a7a22656e6900725ba0076c22e54ee6174479d56ceef97bed7257bffbe74d195a3a2efcb5b0cbf7339cad63
|
7
|
+
data.tar.gz: 9c7f27cf75762c7c440fb4f64c9a6b4d2adad5231bdf143b516a55af37b0e65243d45e3a7b268d0f2d61d1105f7178935bc5d223570e0a0dcde63e720e3fd2ab
|
data/lib/pg/doc.rb
CHANGED
data/lib/pg/doc/engine.rb
CHANGED
@@ -67,7 +67,8 @@ module PG
|
|
67
67
|
h[:schemas][row["schema_name"]] = {
|
68
68
|
tables: {},
|
69
69
|
views: {},
|
70
|
-
functions: {}
|
70
|
+
functions: {},
|
71
|
+
triggers: {}
|
71
72
|
}
|
72
73
|
}
|
73
74
|
|
@@ -81,6 +82,7 @@ module PG
|
|
81
82
|
information_schema.tables
|
82
83
|
WHERE
|
83
84
|
#{@schema_filter.call :table_schema}
|
85
|
+
AND table_type != 'VIEW'
|
84
86
|
ORDER BY
|
85
87
|
1, 2
|
86
88
|
SQL
|
@@ -150,6 +152,8 @@ module PG
|
|
150
152
|
routine_definition,
|
151
153
|
external_language,
|
152
154
|
pg_get_function_identity_arguments((routine_schema || '.' || routine_name)::regproc) as arguments,
|
155
|
+
pg_get_functiondef((routine_schema || '.' || routine_name)::regproc) as function_definition,
|
156
|
+
pg_get_function_result((routine_schema || '.' || routine_name)::regproc) as function_result,
|
153
157
|
obj_description((routine_schema || '.' || routine_name)::regproc::oid, 'pg_proc') as comment
|
154
158
|
FROM
|
155
159
|
information_schema.routines
|
@@ -160,10 +164,13 @@ module PG
|
|
160
164
|
1, 2
|
161
165
|
SQL
|
162
166
|
_recordset.each_with_object(@cache){ |row, h|
|
163
|
-
|
167
|
+
dest = row["function_result"] == "trigger" ? :triggers : :functions
|
168
|
+
h[:schemas][row["routine_schema"]][dest][row["routine_name"]] = {
|
164
169
|
external_language: row["external_language"],
|
165
170
|
comment: row["comment"],
|
166
|
-
arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg }
|
171
|
+
arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg },
|
172
|
+
function_definition: row["function_definition"],
|
173
|
+
function_result: row["function_result"]
|
167
174
|
}
|
168
175
|
}
|
169
176
|
|
@@ -271,7 +278,7 @@ module PG
|
|
271
278
|
type = arg
|
272
279
|
end
|
273
280
|
|
274
|
-
{name
|
281
|
+
{"name" => name, "type" => type, "mode" => argmode}
|
275
282
|
|
276
283
|
end
|
277
284
|
|
data/lib/pg/doc/version.rb
CHANGED
data/static/pg-doc.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
$(document).ready(() =>
|
1
|
+
$(document).ready(() => {
|
2
2
|
|
3
3
|
// Toggles submenues in navigation
|
4
4
|
$(document).on("click", ".js-submenu", (event) => {
|
@@ -6,4 +6,9 @@ $(document).ready(() =>
|
|
6
6
|
$(event.currentTarget).next("DIV.menu").transition('toggle')
|
7
7
|
})
|
8
8
|
|
9
|
-
|
9
|
+
// Handles code highlighting
|
10
|
+
$('PRE').each((i, block) => {
|
11
|
+
hljs.highlightBlock(block)
|
12
|
+
})
|
13
|
+
|
14
|
+
});
|
@@ -34,7 +34,14 @@
|
|
34
34
|
<% unless data[:functions].empty? %>
|
35
35
|
<div class="subheader">Functions</div>
|
36
36
|
<% data[:functions].each do |routine_name, routine| %>
|
37
|
-
<a class="item" href="<%= url "/schemas/#{schema}/functions/#{routine_name}" %>"><span><i class="
|
37
|
+
<a class="item" href="<%= url "/schemas/#{schema}/functions/#{routine_name}" %>"><span><i class="code icon"></i> <%= routine_name %></span></a>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<% unless data[:triggers].empty? %>
|
42
|
+
<div class="subheader">Triggers</div>
|
43
|
+
<% data[:triggers].each do |routine_name, routine| %>
|
44
|
+
<a class="item" href="<%= url "/schemas/#{schema}/triggers/#{routine_name}" %>"><span><i class="lightning icon"></i> <%= routine_name %></span></a>
|
38
45
|
<% end %>
|
39
46
|
<% end %>
|
40
47
|
|
data/views/layout.erb
CHANGED
@@ -10,10 +10,13 @@
|
|
10
10
|
<title>Database Documentation</title>
|
11
11
|
|
12
12
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
|
13
|
+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/foundation.min.css">
|
13
14
|
<link rel="stylesheet" type="text/css" href="<%= url '/style.css' %>">
|
14
15
|
|
15
16
|
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
|
16
17
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>
|
18
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
19
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/sql.min.js"></script>
|
17
20
|
<script src="<%= url '/pg-doc.js' %>"></script>
|
18
21
|
|
19
22
|
</head>
|
data/views/objects/function.erb
CHANGED
@@ -1 +1,33 @@
|
|
1
|
-
|
1
|
+
<h1>
|
2
|
+
<%= object[:external_language]%> Function - <code><%= params["schema"] %>.<%= params["name"] %></code>
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
<% if object[:comment] %>
|
6
|
+
<h2>Description</h2>
|
7
|
+
<p><%= object[:comment] %></p>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= render_markdown "schema/#{params["schema"]}/functions/#{params["name"]}.md" %>
|
11
|
+
|
12
|
+
<h2>Function Arguments</h2>
|
13
|
+
<table class="ui compact fixed celled table">
|
14
|
+
<thead>
|
15
|
+
<th>Argument Name</th>
|
16
|
+
<th>Data Type</th>
|
17
|
+
<th>Argument Mode</th>
|
18
|
+
</thead>
|
19
|
+
<tbody>
|
20
|
+
<% object[:arguments].each do |row| %>
|
21
|
+
<tr>
|
22
|
+
<td><%= row["name"] %></td>
|
23
|
+
<td><%= row["type"] %></td>
|
24
|
+
<td><%= row["mode"] %></td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
|
30
|
+
<% if object[:function_definition] %>
|
31
|
+
<h2>Function Definition</h2>
|
32
|
+
<pre class="ui segment sql"><%= CGI.escapeHTML object[:function_definition] %></pre>
|
33
|
+
<% end %>
|
data/views/objects/table.erb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1>
|
2
|
+
<%= object[:external_language]%> Trigger - <code><%= params["schema"] %>.<%= params["name"] %></code>
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
<% if object[:comment] %>
|
6
|
+
<h2>Description</h2>
|
7
|
+
<p><%= object[:comment] %></p>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= render_markdown "schema/#{params["schema"]}/triggers/#{params["name"]}.md" %>
|
11
|
+
|
12
|
+
<% if object[:function_definition] %>
|
13
|
+
<h2>Trigger Definition</h2>
|
14
|
+
<pre class="ui segment sql"><%= CGI.escapeHTML object[:function_definition] %></pre>
|
15
|
+
<% end %>
|
data/views/objects/view.erb
CHANGED
@@ -1 +1,33 @@
|
|
1
|
-
<
|
1
|
+
<h1>
|
2
|
+
View - <code><%= params["schema"] %>.<%= params["name"] %></code>
|
3
|
+
</h1>
|
4
|
+
|
5
|
+
<% if object[:comment] %>
|
6
|
+
<h2>Description</h2>
|
7
|
+
<p><%= object[:comment] %></p>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= render_markdown "schema/#{params["schema"]}/views/#{params["name"]}.md" %>
|
11
|
+
|
12
|
+
<table class="ui compact fixed celled table">
|
13
|
+
<thead>
|
14
|
+
<th>Column Name</th>
|
15
|
+
<th>Data Type</th>
|
16
|
+
<th>Comment</th>
|
17
|
+
</thead>
|
18
|
+
<tbody>
|
19
|
+
<% object[:columns].each do |row| %>
|
20
|
+
<tr>
|
21
|
+
<td><%= row["column_name"] %></td>
|
22
|
+
<td><%= row["data_type"] %></td>
|
23
|
+
<td><%= row["comment"] %></td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<h2>View Definition</h2>
|
30
|
+
|
31
|
+
<pre class="ui segment sql">
|
32
|
+
<%= CGI.escapeHTML object[:view_definition] %>
|
33
|
+
</pre>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg-doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenaniah Cerny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- views/objects/function.erb
|
170
170
|
- views/objects/schema.erb
|
171
171
|
- views/objects/table.erb
|
172
|
+
- views/objects/trigger.erb
|
172
173
|
- views/objects/view.erb
|
173
174
|
homepage: https://github.com/kenaniah/pg-doc
|
174
175
|
licenses:
|