This PR fixes the issue where executing deno doc on a TypeScript file that starts with a shebang line (#!/usr/bin/env -S deno run --allow-net --allow-read) causes the documentation generation to ignore module docs.
Problem
Currently, files that include a shebang line skip the module docs, leading to incomplete documentation. This issue occurs because the method parsed_source.get_leading_comments() in the swc.rs file returns None when there is a shebang line. The byte position for the leading comments is not at program.start() due to the shebang line, causing the comments to be missed.
Example
An example of a TypeScript file starting with a shebang line that faces this issue can be seen here.
Solution
Added logic to adjust the position of the leading comments when a shebang line is present.
Refactored the relevant code in swc.rs to correctly identify and include leading comments after the shebang line.
Updated tests to ensure that files both with and without shebang lines are processed correctly.
Changes
Modified swc.rs to handle the new position of leading comments when a shebang line is present.
Added tests in tests/specs to cover use case with shebang lines.
Summary
This PR fixes the issue where executing
deno doc
on a TypeScript file that starts with a shebang line (#!/usr/bin/env -S deno run --allow-net --allow-read
) causes the documentation generation to ignore module docs.Problem
Currently, files that include a shebang line skip the module docs, leading to incomplete documentation. This issue occurs because the method
parsed_source.get_leading_comments()
in theswc.rs
file returnsNone
when there is a shebang line. The byte position for the leading comments is not atprogram.start()
due to the shebang line, causing the comments to be missed.Example
An example of a TypeScript file starting with a shebang line that faces this issue can be seen here.
Solution
swc.rs
to correctly identify and include leading comments after the shebang line.Changes
swc.rs
to handle the new position of leading comments when a shebang line is present.tests/specs
to cover use case with shebang lines.Fix issues