New option to include Python docstrings in the output JS as JSDoc
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, python
- Lĩnh vực
- compilers
Hướng nghiên cứu
Start in compiler.py around line 2664 and inspect how the existing -d option handles docstrings. Determine how a separate option should emit Python docstrings as JSDoc, then verify the generated output against the example shown in the issue and add appropriate coverage if the repository provides a compiler test entry point.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The repo I am using Transcrypt for (e-mission-common) is a standalone library that gets distributed as both a JS package (npm) and a Python package (pip).
I'm gradually adding inline documentation in the Python source via docstrings so that when people import the library for use in Python projects they can benefit from autocompletion and inline documentation in their IDE.
But when imported into JS projects, this doesn't work because Transcrypt doesn't convert docstrings to the JS equivalent (which would be JSDoc)
It's possible to use the -d option to get Transcrypt to include the docstrings in the output JS, but doesn't achieve what I want.
Example function:
def sum(a, b):
"""
Adds two numbers and returns the result
@param a: The first number
@param b: The second number
@return: The sum of the two numbers
"""
return a + b
Output JS using -d:
export var sum = function (a, b) {
return a + b;
} .__setdoc__ ('Adds two numbers and returns the result\n \n @param a: The first number\n @param b: The second number\n @return: The sum of the two numbers');
What I want:
/**
* Adds two numbers and returns the result
*
* @param a: The first number
* @param b: The second number
* @return: The sum of the two numbers
*/
export var sum = function (a, b) {
return a + b;
}
I was actually able to achieve this result by adding this bit of code in compiler.py, around line 2664
docString = ast.get_docstring(node)
if docString:
self.emit('/**\n * {}\n */\n', docString.replace('\n', '\n * ').replace('\'', '\\\''))
But before I created a PR, I wanted to first file an issue proposing this to see if it would be accepted.
- Ngôn ngữ chính
- Python
- Star
- 2.9k
- Fork
- 218
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TranscryptOrg/Transcrypt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TranscryptOrg/Transcrypt#913 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
TranscryptOrg/Transcrypt#911 · 2 bình luận ·
-
IS: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
TranscryptOrg/Transcrypt#656 · 7 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
TranscryptOrg/Transcrypt#914 ·
Tất cả issue của TranscryptOrg/Transcrypt
Issue tương tự
-
triage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/cloudstack#14222 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100