feat: include python (w/ sphinx) support #3
feat: include python (w/ sphinx) support #3gbrasil720 wants to merge 2 commits intospacelaxy:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive Python Sphinx documentation support to the extension. It enables syntax highlighting, code completion, and parsing for Python docstrings using Sphinx/reStructuredText conventions like :param, :returns, and :raises tags.
Key changes:
- Added Python parser for extracting and parsing Sphinx-style docstrings
- Updated configuration to properly detect Python docstrings and exclude Python from hash-based comment detection
- Refactored completion provider to support dynamic pattern fetching and Python docstring detection
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/parsers/python.parser.ts | New parser implementation for Python Sphinx docstrings |
| src/providers/comment-highlight.provider.ts | Added Python-specific highlighting logic for docstrings |
| src/providers/comment-completion.provider.ts | Refactored to support dynamic patterns and Python docstring detection |
| src/config/parser-patterns.config.ts | Added Python-specific regex patterns for docstring parsing |
| src/config/language.config.ts | Updated language configuration for Python docstring support |
| src/config/default-patterns.config.ts | Added Sphinx tag patterns for highlighting |
| src/parsers/index.ts | Registered new Python parser |
| src/extension.ts | Streamlined extension activation logic |
| README.md | Added Python/Sphinx documentation and examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| export const PARSERS = [ | ||
| new CSharpParser(), | ||
| new CppParser(), | ||
| new CppParser(), | ||
| new CppParser(), | ||
| new JavaParser(), | ||
| new JavaScriptParser(), | ||
| new JavaScriptParser(), | ||
| new PHPParser(), | ||
| new RustParser(), | ||
| new PythonParser(), | ||
| ]; | ||
|
|
There was a problem hiding this comment.
Duplicate parser instances are being created. Lines 12-14 create three CppParser instances and lines 16-17 create two JavaScriptParser instances. This array appears to be unused but creates unnecessary object instances.
| export const PARSERS = [ | |
| new CSharpParser(), | |
| new CppParser(), | |
| new CppParser(), | |
| new CppParser(), | |
| new JavaParser(), | |
| new JavaScriptParser(), | |
| new JavaScriptParser(), | |
| new PHPParser(), | |
| new RustParser(), | |
| new PythonParser(), | |
| ]; |
| if(this.isInsideComment(document, position)) { | ||
| const completionItems = commentPatterns.map(pattern => { | ||
| const item = new vscode.CompletionItem(pattern.pattern, vscode.CompletionItemKind.Text); | ||
| item.insertText = pattern.pattern.startsWith('@') ? pattern.pattern.substring(1) : pattern.pattern; |
There was a problem hiding this comment.
The completion logic is inconsistent. Line 11 uses the full pattern as the label, but line 12 removes the '@' prefix for insertion. This creates confusing completion items where the displayed text doesn't match what gets inserted.
| item.insertText = pattern.pattern.startsWith('@') ? pattern.pattern.substring(1) : pattern.pattern; | |
| item.insertText = pattern.pattern; |
| ConfigurationService.onConfigurationChanged(() => { | ||
|
|
||
| }); |
There was a problem hiding this comment.
Empty configuration change handler serves no purpose. The previous implementation updated completion patterns when configuration changed, but this functionality has been removed without explanation.
|
I tested the extension with the proposed Python Sphinx documentation support, but I ran into several issues that prevent merging at this time:
Given these conflicts and bugs, I recommend holding off on this PR until the issues are resolved. Once these points are addressed, the extension can be safely merged with full Python Sphinx support. |
This pull request adds full support for Python Sphinx-style documentation comments to the extension, including syntax highlighting, completion, and parsing. The main changes introduce a new parser for Python docstrings, update configuration to recognize Sphinx patterns, and improve completion and detection logic for Python comments.
Python Sphinx Documentation Support
README.md. [1] [2]Configuration Updates
:param,:returns,:raises) to the default comment patterns for highlighting and completion insrc/config/default-patterns.config.ts.src/config/language.config.ts. [1] [2] [3]Parser and Pattern Recognition
PythonParserfor extracting and parsing Sphinx-style docstrings, including handling parameters, return values, types, and exceptions insrc/parsers/python.parser.tsand registered it in the parser factory. [1] [2] [3]src/config/parser-patterns.config.ts. [1] [2] [3] [4] [5]Completion and Extension Logic
src/extension.tsandsrc/providers/comment-completion.provider.ts. [1] [2]