denoland / deno_doc

Documentation generator for Deno
MIT License
253 stars 54 forks source link

fix(docs): fix ignoring generting module documentation when the source code starts with shebang line #605

Closed MujahedSafaa closed 2 months ago

MujahedSafaa commented 2 months ago

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 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

Changes

Fix issues

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

MujahedSafaa commented 2 months ago

Hello @dsherret @lucacasonato Could you please review my PR?

iuioiua commented 2 months ago

Please run cargo fmt.

MujahedSafaa commented 2 months ago

Please run cargo fmt.

Done