Skip to content

Commit cc7f8c8

Browse files
authored
Merge pull request #1 from Theile/1.0.0
1.0.0
2 parents 8a9f409 + 63afef7 commit cc7f8c8

File tree

8 files changed

+58
-77
lines changed

8 files changed

+58
-77
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to the "shell-function-landmark-outline" extension will be d
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.0] - 2025-01-23
9+
10+
- Initial release
11+
812
## [0.9.0] - 2025-01-22
913

10-
- Initial release
14+
- First try, but not as expected.

README.md

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,40 @@
1-
# Shell script function and landmark outline 0.9.0
1+
# Shell script functions and tags outline 1.0.0
22

3-
## `shell-function-landmark-outline`
3+
## `shell-function-tag-outline`
44

5-
Provide outline view for Shell script functions and landmarks.
5+
Provide outline view for Shell script functions and tags.
66

7-
Regex:
8-
```
9-
^([ \t]*)(function[ \t]+)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{(])[^(]?
7+
### Functions
108

11-
'^([ \t]*|[ \t]*\#*[ \t]*)((function[ \t]+)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{(])[^(]?|MARK:.*|NOTE:.*|REVIEW:.*|TODO:.*|FIXME:.*|!!!:.*|\?\?\?:.*)'
12-
 
13-
'^([ \t]*|[ \t]*\#*[ \t]*)((function[ \t]+)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{])[^(]?|MARK:.*|NOTE:.*|REVIEW:.*|TODO:.*|FIXME:.*|!!!:.*|\?\?\?:.*)'
9+
Whenever a function is defined in the script it will be placed in the outline.
1410

11+
### Comment tags
1512

16-
^([ \t]*|[ \t]*\#+[ \t]+)(function[ \t]+)?(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)?(:[ \t]*)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{(])[^(]?
13+
These special comments begin with a certain *tag* identifier. When one of the below *tags* are used they will appear in the outline with an icon:
1714

18-
type = matched[8]+matched[10]
19-
name = matched[6]+matched[12]
20-
^(([ \t]*)(function[ \t]+)?()()([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))+[ \t*]*([{\(])[^(]?|([ \t]*[#]+[ \t]+)(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)(:[ \t]*)(.*)()())
15+
- `# MARK:`
16+
- `# NOTE:`
17+
- `# REVIEW:`
18+
- `# TODO:`
19+
- `# FIXME:`
20+
- `# HACK:`
21+
- `# BUG:`
22+
- `# OPTIMIZE:`
23+
- `# !!!:`
24+
- `# ???:`
2125

22-
const test = matched[8];
23-
if(test) {
24-
const type = matched[8];
25-
const name = matched[6];
26-
} else {
27-
const type = matched[10];
28-
const name = matched[12];
29-
}
3026

31-
if(matched[8]) {
32-
const type = matched[8];
33-
const name = matched[6];
34-
} else {
35-
const type = matched[10];
36-
const name = matched[12];
37-
}
27+
![screenshot1](images/screenshot.png)
3828

39-
40-
if(matched[8] === undefined) {
41-
const type = matched[10];
42-
const name = matched[12];
43-
} else {
44-
const type = matched[8];
45-
const name = matched[6];
46-
}
4729

30+
**Based on shell-function-outline v1.2.2 by jannek@aalto 2021**
31+
**Based on perl-outline v0.0.7 by hitode909.**
32+
**They deserves much credit.**
4833

49-
const type = matched[8] ?? const type = matched[10];
50-
const name = matched[6] ?? const name = matched[12];
51-
52-
53-
54-
```
55-
56-
### Landmarks
57-
58-
Landmarks are shell script comments that begin with a certain landmark identifier:
34+
## Future idea
5935

60-
- `# MARK:` Shown as
61-
- `# NOTE:` Shown as
62-
- `# REVIEW:` Shown as
63-
- `# TODO:` Shown as
64-
- `# FIXME:` Shown as
65-
- `# !!!:` Shown as
66-
- `# ???:` Shown as
36+
Some editors handle this comment tag dash with a separator before the line:
6737

68-
**Based on shell-function-outline v1.2.2 by jannek@aalto 2021**
69-
**Based on perl-outline v0.0.7 by hitode909.**
70-
**They deserves all credit.**
38+
- `# MARK: - Headline notation`
7139

72-
![screenshot1](images/screenshot.png)
40+
Could be interesting if that could be implemented.

TEST-script.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@
1111
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1212
# NOTE: Calculated constants with checks
1313

14+
# OPTIMIZE: Runs slow, can it be faster?
1415
printlog() { # 1: Argument to print
1516
timestamp=$(date +%F\ %T)
1617
# ???: Is this working?
1718
echo "$timestamp : [${funcstack[2]}] $1"
1819
}
1920

21+
# MARK: - Headline notation
22+
# ERROR: Not really a valid function
2023
function testing () (
21-
# Test function
24+
# HACK: Fixed value
25+
2226
# FIXME: Not done with this function
2327
)
2428

29+
# BUG: Needs fixing
2530
function extra_test () {
26-
# TODO: Also needed
31+
# TODO: Better ending
2732
}
2833
# TODO: Also needed functionality
2934
# !!!: Important addition

images/screenshot.png

217 KB
Loading

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"name": "shell-function-landmark-outline",
3-
"displayName": "Shell script function and landmark outline",
4-
"description": "Provide outline view for Shell script functions and landmarks.",
5-
"version": "0.9.0",
2+
"name": "shell-function-tag-outline",
3+
"displayName": "Shell script functions and tags outline",
4+
"description": "Provide outline view for Shell script functions and comment tags.",
5+
"version": "1.0.0",
66
"keywords": [
77
"outline",
88
"shell",
99
"shellscript",
10+
"tag",
1011
"zsh",
1112
"ksh",
1213
"bash",
@@ -15,10 +16,10 @@
1516
"publisher": "Theile",
1617
"repository": {
1718
"type": "git",
18-
"url": "https://github.com/Theile/vscode-shell-function-landmark-outline"
19+
"url": "https://github.com/Theile/vscode-shell-function-tag-outline"
1920
},
2021
"icon": "icon.png",
21-
"homepage": "https://github.com/Theile/vscode-shell-function-landmark-outline",
22+
"homepage": "https://github.com/Theile/vscode-shell-function-tag-outline",
2223
"engines": {
2324
"vscode": "^1.96.0"
2425
},
@@ -41,7 +42,7 @@
4142
"@types/mocha": "^2.2.42",
4243
"@types/node": "^7.10.14",
4344
"tslint": "^5.8.0",
44-
"typescript": "^3.9.7",
45+
"typescript": "^5.7.2",
4546
"vscode": "^1.1.34"
4647
},
4748
"dependencies": {

src/documentSymbolProvider.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class ShellScriptDocumentSymbolProvider implements vscode.DocumentSymbolP
1616
const matchedList = this.matchAll(this.pattern, text);
1717

1818
return matchedList.map((matched) => {
19-
const type = matched[8]+matched[10];
20-
const name = matched[6]+matched[12];
19+
const type = matched[8] ?? matched[10];
20+
const name = matched[6] ?? matched[12];
2121
const kind = tokenToKind[type];
2222

2323
const position = document.positionAt(matched.index || 0);
@@ -37,16 +37,19 @@ export class ShellScriptDocumentSymbolProvider implements vscode.DocumentSymbolP
3737
'(': vscode.SymbolKind.Interface,
3838
'MARK': vscode.SymbolKind.Constructor,
3939
'NOTE': vscode.SymbolKind.Field,
40-
'REVIEW': vscode.SymbolKind.Constant,
41-
'TODO': vscode.SymbolKind.TypeParameter,
40+
'REVIEW': vscode.SymbolKind.TypeParameter,
41+
'TODO': vscode.SymbolKind.Constant,
4242
'FIXME': vscode.SymbolKind.Event,
43+
'HACK': vscode.SymbolKind.Event,
44+
'BUG': vscode.SymbolKind.Null,
45+
'OPTIMIZE': vscode.SymbolKind.EnumMember,
4346
'!!!': vscode.SymbolKind.Event,
4447
'???': vscode.SymbolKind.Enum
4548
};
4649
}
4750

4851
private get pattern() {
49-
return /^(([ \t]*)(function[ \t]+)?()()([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))+[ \t*]*([{\(])[^(]?|([ \t]*[#]+[ \t]+)(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)(:[ \t]*)(.*)()())/gm;
52+
return /^(([ \t]*)(function[ \t]+)?()()([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))+[ \t*]*([{\(])[^(]?|([ \t]*[#]+[ \t]+)(MARK|NOTE|REVIEW|TODO|FIXME|HACK|BUG|OPTIMIZE|!!!|\?\?\?)(:[ \t]*)(.*)()())/gm;
5053
}
5154

5255
private matchAll(

0 commit comments

Comments
 (0)