Skip to content

1.0.0 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to the "shell-function-landmark-outline" extension will be d
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2025-01-23

- Initial release

## [0.9.0] - 2025-01-22

- Initial release
- First try, but not as expected.
82 changes: 25 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,40 @@
# Shell script function and landmark outline 0.9.0
# Shell script functions and tags outline 1.0.0

## `shell-function-landmark-outline`
## `shell-function-tag-outline`

Provide outline view for Shell script functions and landmarks.
Provide outline view for Shell script functions and tags.

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

'^([ \t]*|[ \t]*\#*[ \t]*)((function[ \t]+)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{(])[^(]?|MARK:.*|NOTE:.*|REVIEW:.*|TODO:.*|FIXME:.*|!!!:.*|\?\?\?:.*)'

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

### Comment tags

^([ \t]*|[ \t]*\#+[ \t]+)(function[ \t]+)?(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)?(:[ \t]*)?([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))?[ \t*]*([{(])[^(]?
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:

type = matched[8]+matched[10]
name = matched[6]+matched[12]
^(([ \t]*)(function[ \t]+)?()()([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))+[ \t*]*([{\(])[^(]?|([ \t]*[#]+[ \t]+)(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)(:[ \t]*)(.*)()())
- `# MARK:`
- `# NOTE:`
- `# REVIEW:`
- `# TODO:`
- `# FIXME:`
- `# HACK:`
- `# BUG:`
- `# OPTIMIZE:`
- `# !!!:`
- `# ???:`

const test = matched[8];
if(test) {
const type = matched[8];
const name = matched[6];
} else {
const type = matched[10];
const name = matched[12];
}

if(matched[8]) {
const type = matched[8];
const name = matched[6];
} else {
const type = matched[10];
const name = matched[12];
}
![screenshot1](images/screenshot.png)


if(matched[8] === undefined) {
const type = matched[10];
const name = matched[12];
} else {
const type = matched[8];
const name = matched[6];
}

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

const type = matched[8] ?? const type = matched[10];
const name = matched[6] ?? const name = matched[12];



```

### Landmarks

Landmarks are shell script comments that begin with a certain landmark identifier:
## Future idea

- `# MARK:` Shown as
- `# NOTE:` Shown as
- `# REVIEW:` Shown as
- `# TODO:` Shown as
- `# FIXME:` Shown as
- `# !!!:` Shown as
- `# ???:` Shown as
Some editors handle this comment tag dash with a separator before the line:

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

![screenshot1](images/screenshot.png)
Could be interesting if that could be implemented.
9 changes: 7 additions & 2 deletions TEST-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# NOTE: Calculated constants with checks

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

# MARK: - Headline notation
# ERROR: Not really a valid function
function testing () (
# Test function
# HACK: Fixed value

# FIXME: Not done with this function
)

# BUG: Needs fixing
function extra_test () {
# TODO: Also needed
# TODO: Better ending
}
# TODO: Also needed functionality
# !!!: Important addition
Binary file modified images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "shell-function-landmark-outline",
"displayName": "Shell script function and landmark outline",
"description": "Provide outline view for Shell script functions and landmarks.",
"version": "0.9.0",
"name": "shell-function-tag-outline",
"displayName": "Shell script functions and tags outline",
"description": "Provide outline view for Shell script functions and comment tags.",
"version": "1.0.0",
"keywords": [
"outline",
"shell",
"shellscript",
"tag",
"zsh",
"ksh",
"bash",
Expand All @@ -15,10 +16,10 @@
"publisher": "Theile",
"repository": {
"type": "git",
"url": "https://github.com/Theile/vscode-shell-function-landmark-outline"
"url": "https://github.com/Theile/vscode-shell-function-tag-outline"
},
"icon": "icon.png",
"homepage": "https://github.com/Theile/vscode-shell-function-landmark-outline",
"homepage": "https://github.com/Theile/vscode-shell-function-tag-outline",
"engines": {
"vscode": "^1.96.0"
},
Expand All @@ -41,7 +42,7 @@
"@types/mocha": "^2.2.42",
"@types/node": "^7.10.14",
"tslint": "^5.8.0",
"typescript": "^3.9.7",
"typescript": "^5.7.2",
"vscode": "^1.1.34"
},
"dependencies": {
Expand Down
Binary file not shown.
13 changes: 8 additions & 5 deletions src/documentSymbolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class ShellScriptDocumentSymbolProvider implements vscode.DocumentSymbolP
const matchedList = this.matchAll(this.pattern, text);

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

const position = document.positionAt(matched.index || 0);
Expand All @@ -37,16 +37,19 @@ export class ShellScriptDocumentSymbolProvider implements vscode.DocumentSymbolP
'(': vscode.SymbolKind.Interface,
'MARK': vscode.SymbolKind.Constructor,
'NOTE': vscode.SymbolKind.Field,
'REVIEW': vscode.SymbolKind.Constant,
'TODO': vscode.SymbolKind.TypeParameter,
'REVIEW': vscode.SymbolKind.TypeParameter,
'TODO': vscode.SymbolKind.Constant,
'FIXME': vscode.SymbolKind.Event,
'HACK': vscode.SymbolKind.Event,
'BUG': vscode.SymbolKind.Null,
'OPTIMIZE': vscode.SymbolKind.EnumMember,
'!!!': vscode.SymbolKind.Event,
'???': vscode.SymbolKind.Enum
};
}

private get pattern() {
return /^(([ \t]*)(function[ \t]+)?()()([_A-Za-z][_A-Za-z0-9]+)[ \t]*(\(\))+[ \t*]*([{\(])[^(]?|([ \t]*[#]+[ \t]+)(MARK|NOTE|REVIEW|TODO|FIXME|!!!|\?\?\?)(:[ \t]*)(.*)()())/gm;
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;
}

private matchAll(
Expand Down