Skip to content

fix: resolve shebang parse error in deno doc --test #26079

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 6 commits into from
Apr 16, 2025

Conversation

MujahedSafaa
Copy link
Contributor

@MujahedSafaa MujahedSafaa commented Oct 9, 2024

This PR addresses the issue reported in #26018.

Issue:
Running deno doc --test on a file that contains a shebang results in a parse error.

Solution:
The bug has been fixed by updating the regex to ensure that the shebang characters (#!) are no longer excluded. This allows the shebang to be retained and parsed correctly.
@bartlomieju
@dsherret

Copy link
Member

@magurotuna magurotuna left a comment

Choose a reason for hiding this comment

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

Looks good!
One request though: could you add a test case for a doc test written in markdown? Something like:

# my-awesome-readme

This is a markdown file.

```ts
#!/usr/bin/env -S deno run --allow-read
import { assertEquals } from "@std/assert/equals";
assertEquals(1 + 2, 3);
```

@bartlomieju
Copy link
Member

@MujahedSafaa could you please add a test as pointed above so we can land this PR?

@dsherret dsherret requested a review from magurotuna April 15, 2025 20:32
@dsherret
Copy link
Member

@magurotuna I updated this pr with a test and fix. PTAL

Copy link
Member

@magurotuna magurotuna left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@dsherret dsherret merged commit 302a5dd into denoland:main Apr 16, 2025
18 checks passed
bartlomieju pushed a commit that referenced this pull request Apr 18, 2025
The bug has been fixed by updating the regex to ensure that the shebang
characters (#!) are no longer excluded. This allows the shebang to be
retained and parsed correctly.

---------

Co-authored-by: David Sherret <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants