Skip to content

Commit e91ab72

Browse files
committed
Merge branch 'albert-github-feature/bug_commentview_debug'
2 parents 385a36c + 254f3c9 commit e91ab72

File tree

3 files changed

+81
-7
lines changed

3 files changed

+81
-7
lines changed

addon/doxycommentview/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ The relevant settings, such as alias definitions, will be taken from the Doxyfil
2727
If desired you can set the port for the webserver using `--port` and
2828
point to the location of the doxygen binary using `--doxygen`
2929

30+
Furthermore you can display the doxygen version used at the top of the output using `--version` and
31+
the warnings emitted by doxygen at the bottom of the output by means of `--debug`.
32+
3033
Once the server is started, point your browser to the index page
3134

3235
firefox http://localhost:8000/index.html

addon/doxycommentview/doxycommentview.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import argparse
2222
import signal
2323
import threading
24+
import html
2425

2526
def main():
2627
# Set up argument parser
@@ -33,6 +34,7 @@ def main():
3334
PORT = args.port
3435
DOXYGEN = args.doxygen
3536
DOXYFILE = args.doxyfile
37+
VERSION_STR = subprocess.run([DOXYGEN, '-v'], capture_output=True, text=True, encoding="utf-8").stdout
3638

3739
class RequestHandler(http.server.SimpleHTTPRequestHandler):
3840
def do_POST(self):
@@ -42,15 +44,21 @@ def do_POST(self):
4244
data = json.loads(post_data)
4345
input_text = data['input']
4446

45-
# Run doxygen in single comment mode, reading from stdin and writing to stdout
47+
# Run doxygen in single comment mode, reading from stdin and writing to stdout and stderr
4648
result = subprocess.run([DOXYGEN, '-c', '-', DOXYFILE], \
4749
input=input_text, capture_output=True, text=True, encoding="utf-8")
4850

49-
# Insert CSS link tag into the HTML output
51+
# Prepare the response
52+
response = json.dumps({
53+
'html_output': result.stdout,
54+
'error_output': "<b>Doxygen version "+html.escape(VERSION_STR)+"</b><pre>"+html.escape(result.stderr)+"</pre>"
55+
})
56+
57+
# Send the result to the requesting HTML page
5058
self.send_response(200)
5159
self.send_header('Content-type', 'text/html')
5260
self.end_headers()
53-
self.wfile.write(result.stdout.encode())
61+
self.wfile.write(response.encode())
5462

5563
httpd = socketserver.TCPServer(("", PORT), RequestHandler)
5664

addon/doxycommentview/index.html

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,90 @@
1212
height: 100vh;
1313
}
1414
.panel {
15+
display: flex;
1516
width: 50%;
1617
padding: 20px;
1718
box-sizing: border-box;
1819
}
20+
.line-numbers {
21+
background: #f0f0f0;
22+
padding: 10px;
23+
margin: 0px;
24+
margin-top: 2px;
25+
text-align: right;
26+
user-select: none;
27+
white-space: pre;
28+
border-right: 1px solid #ccc;
29+
font-family: monospace;
30+
font-size: 14px;
31+
line-height: 1.5;
32+
overflow: hidden;
33+
}
1934
#input {
2035
width: 100%;
2136
height: 100%;
37+
padding: 10px;
38+
margin: 0px;
2239
box-sizing: border-box;
23-
resize: none; /* Prevent resizing */
40+
resize: none;
41+
font-family: monospace;
42+
font-size: 14px;
43+
line-height: 1.5;
2444
}
2545
#output {
2646
border-left: 1px solid #ccc;
47+
display: flex;
48+
flex-direction: column;
49+
overflow: hidden;
50+
}
51+
#output-area {
52+
flex: 1;
2753
overflow: auto;
2854
}
55+
#console-area {
56+
height: 150px; /* Fixed height for the console area */
57+
border-top: 1px solid #ccc;
58+
overflow: auto;
59+
background-color: #f9f9f9; /* Light grey background for console area */
60+
padding: 10px;
61+
box-sizing: border-box;
62+
}
2963
</style>
3064
</head>
3165
<body>
3266
<div class="panel">
33-
<textarea id="input"></textarea>
67+
<div class="line-numbers" id="line-numbers">1</div>
68+
<textarea id="input" oninput="updateLineNumbers()" onscroll="syncScroll()" onkeydown="updateLineNumbers()" onkeyup="updateLineNumbers()"></textarea>
3469
</div>
3570
<div class="panel" id="output">
3671
<!-- Processed output will appear here -->
72+
<div id="output-area">
73+
<!-- Processed output will appear here -->
74+
</div>
75+
<div id="console-area">
76+
<!-- Error messages will appear here -->
77+
</div>
3778
</div>
3879
<script>
80+
function updateLineNumbers() {
81+
const textarea = document.getElementById('input');
82+
const lineNumbers = document.getElementById('line-numbers');
83+
84+
const lines = textarea.value.split('\n').length;
85+
let lineNumberString = '';
86+
for (let i = 1; i <= lines; i++) {
87+
lineNumberString += i + '\n';
88+
}
89+
90+
lineNumbers.textContent = lineNumberString;
91+
}
92+
93+
function syncScroll() {
94+
const textarea = document.getElementById('input');
95+
const lineNumbers = document.getElementById('line-numbers');
96+
lineNumbers.scrollTop = textarea.scrollTop;
97+
}
98+
3999
function processInput() {
40100
const input = document.getElementById('input').value;
41101
sessionStorage.setItem('userInput', input);
@@ -46,9 +106,10 @@
46106
},
47107
body: JSON.stringify({ input: input }),
48108
})
49-
.then(response => response.text())
109+
.then(response => response.json())
50110
.then(result => {
51-
document.getElementById('output').innerHTML = result;
111+
document.getElementById('output-area').innerHTML = result.html_output;
112+
document.getElementById('console-area').innerHTML = result.error_output;
52113
});
53114
}
54115

@@ -63,6 +124,8 @@
63124
document.getElementById('input').value = savedInput;
64125
processInput();
65126
}
127+
// Initial line numbers update
128+
updateLineNumbers();
66129
};
67130
</script>
68131
</body>

0 commit comments

Comments
 (0)