Skip to content

Commit e20dccf

Browse files
committed
Refactored schema files of HTML data dicts to use include statement
1 parent 9dfa1e6 commit e20dccf

File tree

7 files changed

+15
-121
lines changed

7 files changed

+15
-121
lines changed

assets/schemas/datadict/html/datadict.sch

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,12 @@
22
# CAUTION: Do not modify this file unless you know what you are doing.
33
# Code generation can be broken if incorrect changes are made.
44

5-
<html> \n
6-
<head> \n
7-
[ <meta charset="utf-8">
8-
<title>Data dictionary generated by pgModeler</title> ] \n
9-
10-
%if {split} %then
11-
[ <link rel="stylesheet" type="text/css" href="styles.css"> ] \n
12-
%else
13-
[ <style> ] \n
14-
{styles} \n
15-
[ </style> ] \n
16-
%end
17-
18-
</head> \n
19-
<body> \n
5+
@include "header"
206

217
%if %not {split} %and {datadictidx} %then
228
{datadictidx}
239
%end
2410

2511
{objects}
2612

27-
[ <footer>
28-
Generated at <em> ] {date} [ </em> by <strong>pgModeler ] {version} [ </strong><br/>
29-
<a href="https://pgmodeler.io">PostgreSQL Database Modeler - https://pgmodeler.io</a><br/>
30-
Copyright © 2006 - ] {year} [ Raphael Araújo e Silva
31-
</footer> ]
32-
33-
</body> \n
34-
</html> \n
13+
@include "footer"

assets/schemas/datadict/html/datadictidx.sch

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
# CAUTION: Do not modify this file unless you know what you are doing.
33
# Code generation can be broken if incorrect changes are made.
44

5-
%set {spc} \n \s
5+
@include "header"
66

7-
%if {split} %then
8-
[ <html>
9-
<head>
10-
<meta charset="utf-8">
11-
<title>Data dictionary generated by pgModeler</title>
12-
<link rel="stylesheet" type="text/css" href="styles.css">
13-
</head>
14-
<body> ]
15-
%end
7+
%set {spc} \n \s
168

179
\n [ <h2>Data dictionary index</h2> ]
1810

@@ -47,12 +39,5 @@
4739
\n
4840

4941
%if {split} %then
50-
51-
[ <footer>
52-
Generated by <a href="https://pgmodeler.io"> PostgreSQL Database Modeler - pgModeler</a><br/>
53-
Copyright © 2006 - ] {year} [ Raphael Araújo e Silva
54-
</footer> ]
55-
56-
</body> \n
57-
</html>
42+
@include "footer"
5843
%end

assets/schemas/datadict/html/table.sch

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,4 @@
9393

9494
\n </table> \n
9595

96-
97-
%if {datadictidx} %then
98-
\n <div>
99-
100-
%if {split} %and {previous} %then
101-
{spc} <a \s href="{previous}.html" \s class="nav-link"> [&larr;] \s {previous}</a>
102-
%end
103-
104-
%if {split} %then
105-
\n [ <a href="index.html" class="nav-link"> ]
106-
%else
107-
\n [ <a href="#index" class="nav-link"> ]
108-
%end
109-
110-
[&uarr; Index</a> ]
111-
112-
%if {split} %and {next} %then
113-
{spc} <a \s href="{next}.html" \s class="nav-link"> {next} \s [&rarr;] </a>
114-
%end
115-
116-
\n </div> \n
117-
%end
96+
@include "navigation"

assets/schemas/datadict/html/view.sch

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,4 @@
5959

6060
\n </table> \n
6161

62-
%if {datadictidx} %then
63-
\n <div>
64-
65-
%if {split} %and {previous} %then
66-
{spc} <a \s href="{previous}.html" \s class="nav-link"> [&larr;] \s {previous} </a>
67-
%end
68-
69-
%if {split} %then
70-
\n [ <a href="index.html" class="nav-link"> ]
71-
%else
72-
\n [ <a href="#index" class="nav-link"> ]
73-
%end
74-
75-
[ &uarr; Index</a> ]
76-
77-
%if {split} %and {next} %then
78-
{spc} <a \s href="{next}.html" \s class="nav-link"> {next} \s [&rarr;] </a>
79-
%end
80-
81-
\n </div> \n
82-
%end
62+
@include "navigation"

libs/libcore/src/databasemodel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10214,7 +10214,10 @@ void DatabaseModel::getDataDictionary(attribs_map &datadict, bool browsable, boo
1021410214
idx_attribs[BaseObject::getSchemaName(ObjectType::Table)] = "";
1021510215
idx_attribs[BaseObject::getSchemaName(ObjectType::View)] = "";
1021610216
idx_attribs[BaseObject::getSchemaName(ObjectType::ForeignTable)] = "";
10217-
idx_attribs[Attributes::Year] = QString::number(QDate::currentDate().year());
10217+
idx_attribs[Attributes::Year] = attribs[Attributes::Year];
10218+
idx_attribs[Attributes::Date] = attribs[Attributes::Date];
10219+
idx_attribs[Attributes::Styles] = "";
10220+
idx_attribs[Attributes::Version] = GlobalAttributes::PgModelerVersion;
1021810221

1021910222
// Generating the index items
1022010223
for(auto &item : dict_index_list)

libs/libparsers/src/schemaparser.cpp

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool SchemaParser::parseInclude(const QString &include_ln, QString &src_buf, qin
231231
{
232232
throw Exception(Exception::getErrorMessage(ErrorCode::InvalidInclude)
233233
.arg(filename).arg(getCurrentLine()).arg(getCurrentColumn()) + " " +
234-
QString(QT_TR_NOOP("The included file `%1' contains one or more `@include' statements. This isn't currently supported!")).arg(fi.absoluteFilePath()),
234+
QString(QT_TR_NOOP("The included file `%1' contains one or more `%2' statements. This isn't currently supported!")).arg(fi.absoluteFilePath(), TokenInclude),
235235
ErrorCode::InvalidInclude, __PRETTY_FUNCTION__, __FILE__, __LINE__,
236236
nullptr, fi.absoluteFilePath());
237237
}
@@ -261,41 +261,6 @@ bool SchemaParser::parseInclude(const QString &include_ln, QString &src_buf, qin
261261
}
262262
}
263263

264-
/* QString SchemaParser::getParseError(ErrorCode err_code, const QString &extra_msg)
265-
{
266-
int actual_line = line + 1, incl_line = 0, incl_stmt_len = 0;
267-
QString file = filename, msg;
268-
bool is_incl_error = false;
269-
270-
for(auto &info : include_infos)
271-
{
272-
if(info.contains(line))
273-
{
274-
incl_line = info.start_line;
275-
actual_line = (line - info.start_line) + 1;
276-
file = info.include_file;
277-
incl_stmt_len = info.stmt_length;
278-
is_incl_error = true;
279-
break;
280-
}
281-
}
282-
283-
if(is_incl_error)
284-
msg = QString(QT_TR_NOOP("Failed to parse the file `%1' due to an error in the included file at line `%2'. Error detected:\n\n"))
285-
.arg(filename).arg(incl_line + 1);
286-
287-
msg += Exception::getErrorMessage(err_code)
288-
.arg(file).arg(actual_line).arg(column + 1) + " " + extra_msg;
289-
290-
if(is_incl_error)
291-
{
292-
column = incl_stmt_len - 1;
293-
line = incl_line;
294-
}
295-
296-
return msg;
297-
} */
298-
299264
void SchemaParser::loadFile(const QString &filename)
300265
{
301266
if(filename.isEmpty())

libs/libparsers/src/schemaparser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class __libparsers SchemaParser {
200200
QString file = filename, msg;
201201
bool is_incl_error = false;
202202

203+
/* Checking if the current line is associated to a fragment of code
204+
* loaded from an include file */
203205
for(auto &info : include_infos)
204206
{
205207
if(info.contains(line))
@@ -355,6 +357,7 @@ class __libparsers SchemaParser {
355357
//! \brief Returns the current columnm of the current line where the parser is reading
356358
int getCurrentColumn();
357359

360+
//! \brief Set where the schema parser should look for include files used via @include
358361
void setSearchPath(const QString &path);
359362

360363
friend class Catalog;

0 commit comments

Comments
 (0)