New option to include Python docstrings in the output JS as JSDoc
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, python
- Domain
- compilers
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 218
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TranscryptOrg/Transcrypt
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
TranscryptOrg/Transcrypt#913 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
TranscryptOrg/Transcrypt#911 · 2 comments ·
-
IS: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficulty 1/5 Under an hour Newbie friendliness 62/100
TranscryptOrg/Transcrypt#656 · 7 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
TranscryptOrg/Transcrypt#914 ·
All issues in TranscryptOrg/Transcrypt
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·