Skip to content

Commit

Permalink
fix: restore variable documentation (#331)
Browse files Browse the repository at this point in the history
The previous version of `@nginx/reference-lib` did not have NGINX
variables (like `$binary_remote_addr`), update and include those in
the autocomplete array.

The old web scraper included these variables, but often had inaccurate descriptions.

See also: nginx/nginx-directive-reference#203
  • Loading branch information
ryepup authored Jun 11, 2024
1 parent f5f2b58 commit 23a3800
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-editor-nginx",
"version": "2.0.1",
"version": "2.0.2",
"description": "Nginx language for Monaco Editor.",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand All @@ -14,14 +14,14 @@
"license": "MIT",
"peerDependencies": {
"@babel/runtime": ">=7.10.0",
"@nginx/reference-lib": ">=1.0.14",
"@nginx/reference-lib": ">=1.1.0",
"monaco-editor": ">=0.22.3",
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
},
"dependencies": {
"@babel/runtime": "^7.18.6",
"@nginx/reference-lib": "^1.0.14"
"@nginx/reference-lib": "^1.1.0"
},
"devDependencies": {
"monaco-editor": "^0.44.0"
Expand Down
15 changes: 10 additions & 5 deletions core/src/directives.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getDirectives, Format } from '@nginx/reference-lib';
import { Directive } from '@nginx/reference-lib/dist/index.d';
import { getDirectives, Format, getVariables, Directive } from '@nginx/reference-lib';

export type Autocomplete = {
/** name of the NGINX module */
Expand All @@ -12,10 +11,10 @@ export type Autocomplete = {
* nginx config */
v?: string;
/** markdown CSV for valid contexts */
c: string;
c?: string;
/** markdown-formatted syntax specifications, including directive name.
* Multiple syntaxes are seperated by newlines */
s: string;
s?: string;
};

function toAutocomplete(d: Directive): Autocomplete {
Expand All @@ -34,4 +33,10 @@ function toAutocomplete(d: Directive): Autocomplete {
return ret;
}

export const directives = getDirectives(Format.Markdown).map(toAutocomplete);
const variables = getVariables(Format.Markdown).map((v) => ({
m: v.module,
n: v.name,
d: v.description,
}));

export const directives = getDirectives(Format.Markdown).map(toAutocomplete).concat(variables);
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.1",
"version": "2.0.2",
"packages": ["website", "core"]
}
4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website",
"version": "2.0.1",
"version": "2.0.2",
"private": true,
"scripts": {
"start": "kkt start",
Expand All @@ -9,7 +9,7 @@
"license": "MIT",
"dependencies": {
"@wcj/dark-mode": "^1.0.13",
"monaco-editor-nginx": "2.0.1",
"monaco-editor-nginx": "2.0.2",
"react": "~18.2.0",
"react-dom": "~18.2.0"
},
Expand Down

0 comments on commit 23a3800

Please sign in to comment.