Skip to content

Commit

Permalink
[FIX] Whole line comments should be aligned with the line under them (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloRMira authored Jan 23, 2021
1 parent f619279 commit 970e45c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
8 changes: 6 additions & 2 deletions docs/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h2 id="General-formatting">General formatting<a class="anchor-link" href="#Gene
<span class="s2">there */</span>
<span class="s2">case when a.asdf= 1 then &#39;b&#39; /* here a case comment */</span>
<span class="s2">when b.qwer =2 then &#39;c&#39; else &#39;d&#39; end as new_field, -- Some comment</span>
<span class="s2">/* and here some inline comment */</span>
<span class="s2">b.asdf2 frOm table1 as a leFt join </span>
<span class="s2">table2 as b -- and here a comment</span>
<span class="s2"> on a.asdf = b.asdf /* joiN this way */</span>
Expand Down Expand Up @@ -113,6 +114,7 @@ <h2 id="General-formatting">General formatting<a class="anchor-link" href="#Gene
<span class="s2"> case when a.asdf = 1 then &#39;b&#39; /* here a case comment */</span>
<span class="s2"> when b.qwer = 2 then &#39;c&#39;</span>
<span class="s2"> else &#39;d&#39; end as new_field, -- Some comment</span>
<span class="s2"> /* and here some inline comment */</span>
<span class="s2"> b.asdf2</span>
<span class="s2">FROM table1 as a</span>
<span class="s2"> LEFT JOIN table2 as b -- and here a comment</span>
Expand Down Expand Up @@ -475,7 +477,7 @@ <h4 id="clean_query" class="doc_header"><code>clean_query</code><a href="https:/
<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre>create or replace table mytable as -- Mytable example[C][CS]/* multi line[CI]comment */[C]seLecT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then &#39;b&#39; /* here a case comment */[C]when b.qwer =2 then &#39;c&#39; else &#39;d&#39; end as new_field, -- Some comment[C]b.asdf2 frOm table1 as a leFt join table2 as b -- and here a comment[C]on a.asdf = b.asdf /* joiN this way */[C]inner join table3 as c on a.asdf=c.asdf and a.qwer= b.qwer whEre a.asdf= 1 -- comment this[C]anD b.qwer =2 and a.asdf&lt;=1 --comment that[C]or b.qwer&gt;=5 groUp by a.asdf
<pre>create or replace table mytable as -- Mytable example[C][CS]/* multi line[CI]comment */[C]seLecT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then &#39;b&#39; /* here a case comment */[C]when b.qwer =2 then &#39;c&#39; else &#39;d&#39; end as new_field, -- Some comment[C][CS]/* and here some inline comment */[C]b.asdf2 frOm table1 as a leFt join table2 as b -- and here a comment[C]on a.asdf = b.asdf /* joiN this way */[C]inner join table3 as c on a.asdf=c.asdf and a.qwer= b.qwer whEre a.asdf= 1 -- comment this[C]anD b.qwer =2 and a.asdf&lt;=1 --comment that[C]or b.qwer&gt;=5 groUp by a.asdf
</pre>
</div>
</div>
Expand Down Expand Up @@ -1080,7 +1082,7 @@ <h4 id="preformat_statements" class="doc_header"><code>preformat_statements</cod

<div class="output_subarea output_stream output_stdout output_text">
<pre>CREATE OR REPLACE TABLE mytable AS -- Mytable example[C][CS]/* multi line[CI]comment */[C]
SELECT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then &#39;b&#39; /* here a case comment */[C]when b.qwer =2 then &#39;c&#39; else &#39;d&#39; end as new_field, -- Some comment[C]b.asdf2
SELECT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then &#39;b&#39; /* here a case comment */[C]when b.qwer =2 then &#39;c&#39; else &#39;d&#39; end as new_field, -- Some comment[C][CS]/* and here some inline comment */[C]b.asdf2
FROM table1 as a
LEFT JOIN table2 as b -- and here a comment[C]
ON a.asdf = b.asdf /* joiN this way */[C]
Expand Down Expand Up @@ -4071,6 +4073,7 @@ <h4 id="format_simple_sql" class="doc_header"><code>format_simple_sql</code><a h
case when a.asdf = 1 then &#39;b&#39; /* here a case comment */
when b.qwer = 2 then &#39;c&#39;
else &#39;d&#39; end as new_field, -- Some comment
/* and here some inline comment */
b.asdf2
FROM table1 as a
LEFT JOIN table2 as b -- and here a comment
Expand Down Expand Up @@ -4348,6 +4351,7 @@ <h4 id="format_sql" class="doc_header"><code>format_sql</code><a href="https://g
case when a.asdf = 1 then &#39;b&#39; /* here a case comment */
when b.qwer = 2 then &#39;c&#39;
else &#39;d&#39; end as new_field, -- Some comment
/* and here some inline comment */
b.asdf2
FROM table1 as a
LEFT JOIN table2 as b -- and here a comment
Expand Down
21 changes: 12 additions & 9 deletions docs/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -2892,7 +2892,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
<span class="sd"> qwer, /* some comment */</span>
<span class="sd"> case when asdf = 1 and -- comment there</span>
<span class="sd"> asdf = 2 then 2 -- comment here</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> when asdf = 3 then 3 /* bla bla */</span>
<span class="sd"> else 0 end as qwerty,</span>
<span class="sd"> qwer2</span>
Expand All @@ -2914,7 +2914,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
qwer, /* some comment */
case when asdf = 1 and -- comment there
asdf = 2 then 2 -- comment here
/* Whole line comment */
/* Whole line comment */
when asdf = 3 then 3 /* bla bla */
else 0 end as qwerty,
qwer2
Expand Down Expand Up @@ -2958,7 +2958,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
<span class="sd"> qwer, /* some comment */</span>
<span class="sd"> case when asdf = 1 and -- comment there</span>
<span class="sd"> asdf = 2 then 2</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> when asdf = 3 then 3 /* bla bla */</span>
<span class="sd"> else 0 end as qwerty,</span>
<span class="sd"> qwer2</span>
Expand All @@ -2980,7 +2980,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
qwer, /* some comment */
case when asdf = 1 and -- comment there
asdf = 2 then 2
/* Whole line comment */
/* Whole line comment */
when asdf = 3 then 3 /* bla bla */
else 0 end as qwerty,
qwer2
Expand Down Expand Up @@ -3017,7 +3017,8 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;/* some comment */[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;qwer, &quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;-- comment there[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;case when asdf = 1&quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;[CS]/* Whole line comment */[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;and asdf = 2&quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;/* bla bla */[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;then 2 when asdf = 3 then 3&quot;</span><span class="p">}</span>
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;/* bla bla */[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;then 2 when asdf = 3 then 3&quot;</span><span class="p">},</span>
<span class="p">{</span><span class="s2">&quot;comment&quot;</span><span class="p">:</span> <span class="s2">&quot;[CS]/* another whole line comment */[C]&quot;</span><span class="p">,</span> <span class="s2">&quot;preceding&quot;</span><span class="p">:</span> <span class="s2">&quot;else 0 end as qwerty,&quot;</span><span class="p">}</span>
<span class="p">]</span>
<span class="p">),</span>
<span class="sd">&quot;&quot;&quot;</span>
Expand All @@ -3026,9 +3027,10 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
<span class="sd"> qwer, /* some comment */</span>
<span class="sd"> case when asdf = 1 and -- comment there</span>
<span class="sd"> asdf = 2 then 2</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> when asdf = 3 then 3 /* bla bla */</span>
<span class="sd"> else 0 end as qwerty,</span>
<span class="sd"> /* another whole line comment */</span>
<span class="sd"> qwer2</span>
<span class="sd">&quot;&quot;&quot;</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="p">)</span>
Expand All @@ -3049,9 +3051,10 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
qwer, /* some comment */
case when asdf = 1 and -- comment there
asdf = 2 then 2
/* Whole line comment */
/* Whole line comment */
when asdf = 3 then 3 /* bla bla */
else 0 end as qwerty,
/* another whole line comment */
qwer2
</pre>
</div>
Expand Down Expand Up @@ -3095,7 +3098,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
<span class="sd"> qwer, /* some comment */</span>
<span class="sd"> case when asdf = 1 and -- comment there</span>
<span class="sd"> asdf = 2 then 2</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> /* Whole line comment */</span>
<span class="sd"> when asdf = 3 then 3 /* bla bla */</span>
<span class="sd"> else 0 end as qwerty,</span>
<span class="sd"> qwer2</span>
Expand All @@ -3118,7 +3121,7 @@ <h4 id="assign_comment" class="doc_header"><code>assign_comment</code><a href="h
qwer, /* some comment */
case when asdf = 1 and -- comment there
asdf = 2 then 2
/* Whole line comment */
/* Whole line comment */
when asdf = 3 then 3 /* bla bla */
else 0 end as qwerty,
qwer2
Expand Down
8 changes: 6 additions & 2 deletions nbs/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"there */\n",
"case when a.asdf= 1 then 'b' /* here a case comment */\n",
"when b.qwer =2 then 'c' else 'd' end as new_field, -- Some comment\n",
"/* and here some inline comment */\n",
"b.asdf2 frOm table1 as a leFt join \n",
"table2 as b -- and here a comment\n",
" on a.asdf = b.asdf /* joiN this way */\n",
Expand Down Expand Up @@ -121,6 +122,7 @@
" case when a.asdf = 1 then 'b' /* here a case comment */\n",
" when b.qwer = 2 then 'c'\n",
" else 'd' end as new_field, -- Some comment\n",
" /* and here some inline comment */\n",
" b.asdf2\n",
"FROM table1 as a\n",
" LEFT JOIN table2 as b -- and here a comment\n",
Expand Down Expand Up @@ -389,7 +391,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"create or replace table mytable as -- Mytable example[C][CS]/* multi line[CI]comment */[C]seLecT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then 'b' /* here a case comment */[C]when b.qwer =2 then 'c' else 'd' end as new_field, -- Some comment[C]b.asdf2 frOm table1 as a leFt join table2 as b -- and here a comment[C]on a.asdf = b.asdf /* joiN this way */[C]inner join table3 as c on a.asdf=c.asdf and a.qwer= b.qwer whEre a.asdf= 1 -- comment this[C]anD b.qwer =2 and a.asdf<=1 --comment that[C]or b.qwer>=5 groUp by a.asdf\n"
"create or replace table mytable as -- Mytable example[C][CS]/* multi line[CI]comment */[C]seLecT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then 'b' /* here a case comment */[C]when b.qwer =2 then 'c' else 'd' end as new_field, -- Some comment[C][CS]/* and here some inline comment */[C]b.asdf2 frOm table1 as a leFt join table2 as b -- and here a comment[C]on a.asdf = b.asdf /* joiN this way */[C]inner join table3 as c on a.asdf=c.asdf and a.qwer= b.qwer whEre a.asdf= 1 -- comment this[C]anD b.qwer =2 and a.asdf<=1 --comment that[C]or b.qwer>=5 groUp by a.asdf\n"
]
}
],
Expand Down Expand Up @@ -829,7 +831,7 @@
"output_type": "stream",
"text": [
"CREATE OR REPLACE TABLE mytable AS -- Mytable example[C][CS]/* multi line[CI]comment */[C]\n",
"SELECT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then 'b' /* here a case comment */[C]when b.qwer =2 then 'c' else 'd' end as new_field, -- Some comment[C]b.asdf2\n",
"SELECT a.asdf, b.qwer, -- some comment here[C][CS]/* and here is a line comment inside select */[C]substr(c.asdf, 1, 2) as substr_asdf,[CS]/* some commenT[CI]there */[C]case when a.asdf= 1 then 'b' /* here a case comment */[C]when b.qwer =2 then 'c' else 'd' end as new_field, -- Some comment[C][CS]/* and here some inline comment */[C]b.asdf2\n",
"FROM table1 as a\n",
"LEFT JOIN table2 as b -- and here a comment[C]\n",
"ON a.asdf = b.asdf /* joiN this way */[C]\n",
Expand Down Expand Up @@ -2978,6 +2980,7 @@
" case when a.asdf = 1 then 'b' /* here a case comment */\n",
" when b.qwer = 2 then 'c'\n",
" else 'd' end as new_field, -- Some comment\n",
" /* and here some inline comment */\n",
" b.asdf2\n",
"FROM table1 as a\n",
" LEFT JOIN table2 as b -- and here a comment\n",
Expand Down Expand Up @@ -3198,6 +3201,7 @@
" case when a.asdf = 1 then 'b' /* here a case comment */\n",
" when b.qwer = 2 then 'c'\n",
" else 'd' end as new_field, -- Some comment\n",
" /* and here some inline comment */\n",
" b.asdf2\n",
"FROM table1 as a\n",
" LEFT JOIN table2 as b -- and here a comment\n",
Expand Down
Loading

0 comments on commit 970e45c

Please sign in to comment.