Skip to content

Commit 6a829c3

Browse files
committed
update to version 0.2.0
1 parent a633f92 commit 6a829c3

File tree

9 files changed

+88
-2985
lines changed

9 files changed

+88
-2985
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1919
## [0.1.0] - 2023-10-14
2020

2121
- Update of `patterns.json` file and `headings.md` file. Additional regular expressions added to the list used to parse the ORCA output file. Most frequently used keywords in the ORCA output file are now parsed. The list of regular expressions will be updated in future releases.
22+
23+
## [0.2.0] - 2023-10-15
24+
25+
- This version removed the previous `generate_patterns.py` script and the `headings.md` file. The list of regular expressions in `patterns.json` file is now more unversal and the matched text is displayed in the `ORCA FILE OUTLINE` view. Most of the keywords in the ORCA output file are in full capital letters, which is not very user friendly. The matched text is now converted to title case before being displayed in the `ORCA FILE OUTLINE` view. There is a list of keywords in the `keywords.json` file, which will be used to replace some of the converted matched text to its correct form. The list of keywords will be updated in future small releases.

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ This an extension for Visual Studio Code that provides a separate toggleable TOC
44

55
## Features
66

7-
This extension provides a separate toggleable TOC view in the sidebar. The TOC view is automatically populated with the contents of the ORCA output file that is currently open in the editor. The TOC view is generated by parsing the ORCA output file using regular expressions and setting up a tree view based on the results. The generated TOC view is a tree view with the titles of the headings in the ORCA output file and the corresponding line numbers. Clicking on a TOC entry will jump to the corresponding line in the ORCA output file. The TOC view can be toggled on and off by clicking on the `Orca Outline` icon in the sidebar. The TOC view can also be toggled on by running the command `Show Orca Outline` from the command palette. On Windows, the command palette can be opened with `Ctrl+Shift+P`, on Mac it is `Cmd+Shift+P`. The TOC view is automatically updated when navigating to a different ORCA output file.
7+
This extension provides a separate toggleable TOC view in the sidebar. The TOC view is automatically populated with the contents of the ORCA output file that is currently open in the editor. The TOC view is generated by parsing the ORCA output file using regular expressions and setting up a tree view based on the results. The generated TOC view is a tree view with the titles of the headings in the ORCA output file and the corresponding line numbers. Clicking on a TOC entry will jump to the corresponding line in the ORCA output file. The TOC view can be toggled on and off by clicking on the `ORCA FILE OUTLINE` icon in the sidebar. The TOC view can also be toggled on by running the command `Show ORCA Outline` from the command palette. On Windows, the command palette can be opened with `Ctrl+Shift+P`, on Mac it is `Cmd+Shift+P`. The TOC view is automatically updated when navigating to a different ORCA output file.
88

99
## Requirements
1010

1111
N/A
1212

1313
## Extension Settings
1414

15-
The current version (0.1.0) of this extension does not have any settings.
15+
The current version (0.2.0) of this extension does not have any settings.
1616

1717
## Known Issues
1818

@@ -42,33 +42,32 @@ Added support for automatically showing TOC view when opening an ORCA output fil
4242

4343
Update of `patterns.json` file and `headings.md` file. Additional regular expressions added to the list used to parse the ORCA output file. Most frequently used keywords in the ORCA output file are now parsed. The list of regular expressions will be updated in future releases.
4444

45+
### 0.2.0
46+
47+
This version removed the previous `generate_patterns.py` script and the `headings.md` file. The list of regular expressions in `patterns.json` file is now more unversal and the matched text is displayed in the `ORCA FILE OUTLINE` view. Most of the keywords in the ORCA output file are in full capital letters, which is not very user friendly. The matched text is now converted to title case before being displayed in the `ORCA FILE OUTLINE` view. There is a list of keywords in the `keywords.json` file, which will be used to replace some of the converted matched text to its correct form. The list of keywords will be updated in future small releases.
48+
4549
## TODO
4650

4751
- [x] Automatically show TOC view when opening an ORCA output file
4852
- [ ] Automatically update TOC view when saving changes to an ORCA output file (additional command to manually refresh TOC view)
4953
- [ ] Add support for enabling/disabling TOC view for specific file types
5054
- [ ] Add support for controlling the showing level of TOC entries
5155
- [ ] Add illustrations to this README
52-
- [ ] Add icon to this extension
56+
- [x] Add icon to this extension
5357
- [x] Updating the list of regular expressions used to parse the ORCA output file
5458

5559
## Roadmap
5660

57-
The current version represents a very early release of this extension.
61+
The current version represents a very early release of this extension.
5862

59-
The list of regular expressions in the `headings.md` file is parsed by converting each heading and the corresponding regular expression into a JSON object. The headings that will be displayed in the `ORCA FILE OUTLINE` is the heading text. This approach is not very flexible because some of the headings in the ORCA output file could be changed based on the type of calculation or in different versions of ORCA. In the next major release, the list of regular expressions will be more universal and the matched text will be displayed in the `ORCA FILE OUTLINE` view. The list of regular expressions will be updated in future releases. Most of the keywords in the ORCA output file are in full capital letters, which is not very user friendly. In the next major release, the matched text will be converted to title case before being displayed in the `ORCA FILE OUTLINE` view. There will be a list of keywords that will not be converted to title case. The list of keywords will be updated in future releases.
60-
61-
Another feature that will be added in the next major release is to enable the scrolling of the `ORCA FILE OUTLINE` view to the current line in the ORCA output file. This will be useful when the ORCA output file is very long and the user is navigating through the file. The `ORCA FILE OUTLINE` view will automatically scroll to the current line in the ORCA output file.
63+
An important feature that will be added in the next major release is to enable the scrolling of the `ORCA FILE OUTLINE` view to the current line in the ORCA output file. This will be useful when the ORCA output file is very long and the user is navigating through the file. The `ORCA FILE OUTLINE` view will automatically scroll to the current line in the ORCA output file.
6264

6365
## For Developers
6466

6567
The list of regular expressions is saved in `patterns.json` file. The file contains a list of regular expressions that are used to parse the ORCA output file. Each regular expression is a JSON object with the following properties:
6668

6769
1. `regex`: The regular expression string
6870
2. `level`: The level of the TOC entry (1, 2, 3, etc.)
69-
3. `title`: The title of the TOC entry to be displayed in the TOC view
70-
71-
It is easier to add new headings to the list of regular expressions by editing the `headings.md` file. This file contains a list of regular expressions that are used to parse the ORCA output file. The `generate_patterns.py` script is used to parse the `headings.md` file and generate the `patterns.json` file. The `patterns.json` file is used by the extension to parse the ORCA output file.
7271

7372
Please submit a pull request if you would like to add a new regular expression to the list. Please also submit a pull request if you would like to modify an existing regular expression.
7473

extension.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const path = require('path');
44

55
// Synchronously read orcaPatterns.json
66
const orcaPatterns = JSON.parse(fs.readFileSync(path.join(__dirname, 'patterns.json'), 'utf8'));
7+
const keywordReplacements = JSON.parse(fs.readFileSync(path.join(__dirname, 'keywords.json'), 'utf8'));
78

89
// Adjust regex patterns to RegExp objects
910
orcaPatterns.forEach(pattern => {
1011
pattern.regex = new RegExp(pattern.regex, 'gm');
1112
});
1213

13-
1414
class OrcaOutlineProvider {
1515
constructor(matches) {
1616
this._matches = matches;
@@ -82,31 +82,6 @@ class OrcaOutlineProvider {
8282

8383
let orcaOutlineProvider = new OrcaOutlineProvider([]);
8484

85-
class OrcaDocumentSymbolProvider {
86-
provideDocumentSymbols(document, token) {
87-
const result = [];
88-
89-
orcaPatterns.forEach(pattern => {
90-
let match;
91-
while (match = pattern.regex.exec(document.getText())) {
92-
const position = document.positionAt(match.index);
93-
const range = new vscode.Range(position, position.translate(0, match[0].length));
94-
95-
const symbolInfo = new vscode.DocumentSymbol(
96-
pattern.title,
97-
'',
98-
pattern.level,
99-
range,
100-
range
101-
);
102-
result.push(symbolInfo);
103-
}
104-
});
105-
106-
return result;
107-
}
108-
}
109-
11085
function showOrcaOutline() {
11186
const activeEditor = vscode.window.activeTextEditor;
11287
if (!activeEditor) {
@@ -150,6 +125,12 @@ function activate(context) {
150125

151126
function deactivate() {}
152127

128+
function toTitleCase(str) {
129+
return str.replace(/\w\S*/g, function(txt) {
130+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
131+
});
132+
}
133+
153134
function parseOrcaFile(document, filePath) {
154135
let matches = [];
155136
let stack = [{ children: matches }]; // A default root node for ease of algorithm
@@ -160,9 +141,16 @@ function parseOrcaFile(document, filePath) {
160141
let match;
161142
while (match = pattern.regex.exec(document.getText())) {
162143
const line = document.positionAt(match.index).line;
144+
let title = match[1] || pattern.title;
145+
title = toTitleCase(title.trim());
146+
for (let keyword in keywordReplacements) {
147+
if (title.includes(keyword)) {
148+
title = title.replace(keyword, keywordReplacements[keyword]);
149+
}
150+
}
163151
allMatches.push({
164152
line: line,
165-
title: pattern.title,
153+
title: title,
166154
level: pattern.level,
167155
children: [],
168156
command: {

generate_patterns.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)