Skip to content
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

Add Zig support #389

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions core/Parsing.Documents.fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,17 @@ let mutable languages = [
lang "XML" "xsl" ".xml|.xsl"
html
lang "YAML" "" ".yaml|.yml"
/// Also allow text paragraphs to be wrapped. Though wrapping the whole
/// file at once will mess it up.
// Also allow text paragraphs to be wrapped. Though wrapping the whole
// file at once will mess it up.
Comment on lines +231 to +232
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why adding the Zig entry below causes this error but I was running into this error:

./core/Parsing.Documents.fs(231,9): (232,42) info FSHARP: XML comment is not placed on a valid language element. (code 3520)

<| toNewDocProcessor (fun settings ->
let comments = oldLine "#{1,3}" settings
takeUntil comments (oldPlainText settings) |> repeatToEnd)
lang "Zig" "" ".zig|.zon"
( oldSourceCode
[ customLine DocComments.javadoc "//[/!]"
cLine
]
)
]

/// Creates a custom language parser, if the given CustomMarkers are valid. Also
Expand Down
2 changes: 1 addition & 1 deletion core/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ type Results = {passes:int; failures:int; errors:int}

[<EntryPoint>]
let main argv =
let norm (s: String) = s.ToLower().Replace('\\', '/')
let norm (s: String) = s.Replace('\\', '/')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the tests trying to read differing cased files.

Before this change:

$ node .config/do.mjs test
Error: ENOENT: no such file or directory, open './docs/specs/readme.md'

The actual file name is docs/specs/README.md

Tested on Linux (Manjaro, arch-based)

let argv = Array.map norm argv
let inArgv (f: string) = argv |> Array.exists (fun a -> f.EndsWith (a))
let filesToTest =
Expand Down
17 changes: 17 additions & 0 deletions docs/specs/content-types/zig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
> language: "zig"

Zig uses comment formats that might be familiar if you use Doxygen (C/C++) but there are
no multi-line block comments.

// a b c -> // a b ¦
// d ¦ // c d ¦

Doc comments:

/// a b c -> /// a b ¦
/// d ¦ /// c d ¦

Top-level doc comments:

//! a b c -> //! a b ¦
//! d ¦ //! c d ¦
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"log-update": "^5.0.0",
"parcel": "^2.3.2",
"parcel": "^2.10.2",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated parcel to fix the errors when trying to package things with Node.js 18

See parcel-bundler/parcel#8005

Before this change:

$ node .config/do.mjs package
Bundling Core tests with Parcel...
@parcel/optimizer-terser: You must provide the URL of lib/mappings.wasm by
calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer
  Error: You must provide the URL of lib/mappings.wasm by calling
  SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
  SourceMapConsumer
  at readWasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/read-wasm.js:8:13)
  at wasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/wasm.js:25:16)
  at
  /home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/source-map-consumer.js:264:14
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async SourceMap
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:19362:20)
  at async minify
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:27714:41)
  at async Object.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/optimizer-terser/lib/TerserOptimizer.js:131:16)
  at async PackagerRunner.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:364:20)
  at async PackagerRunner.getBundleResult
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:255:15)
  at async PackagerRunner.getBundleInfo
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:239:9)
Error running: npx --silent parcel build core/test --cache-dir .obj/parcel
@parcel/optimizer-terser: You must provide the URL of lib/mappings.wasm by
calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer
  Error: You must provide the URL of lib/mappings.wasm by calling
  SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
  SourceMapConsumer
  at readWasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/read-wasm.js:8:13)
  at wasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/wasm.js:25:16)
  at
  /home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/source-map-consumer.js:264:14
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async SourceMap
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:19362:20)
  at async minify
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:27714:41)
  at async Object.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/optimizer-terser/lib/TerserOptimizer.js:131:16)
  at async PackagerRunner.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:364:20)
  at async PackagerRunner.getBundleResult
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:255:15)
  at async PackagerRunner.getBundleInfo
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:239:9)

Packaging & Optimizing...
🚨 Build failed.

"typescript": "^4.5.5",
"vsce": "^2.6.7",
"vscode-test": "^1.6.1"
Expand Down