{"id":15009800,"url":"https://github.com/ynshen/dochelper","last_synced_at":"2026-04-06T04:32:34.764Z","repository":{"id":57423206,"uuid":"241492940","full_name":"ynshen/DocHelper","owner":"ynshen","description":"Helper to simplify repeated docstring in a python file","archived":false,"fork":false,"pushed_at":"2020-03-04T00:47:50.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T17:17:18.440Z","etag":null,"topics":["docstring","documentation","python3","utility"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ynshen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-18T23:52:30.000Z","updated_at":"2020-03-04T00:47:52.000Z","dependencies_parsed_at":"2022-09-05T12:30:35.285Z","dependency_job_id":null,"html_url":"https://github.com/ynshen/DocHelper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynshen%2FDocHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynshen%2FDocHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynshen%2FDocHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynshen%2FDocHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ynshen","download_url":"https://codeload.github.com/ynshen/DocHelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258502,"owners_count":20262300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docstring","documentation","python3","utility"],"created_at":"2024-09-24T19:28:39.752Z","updated_at":"2025-12-29T04:03:28.694Z","avatar_url":"https://github.com/ynshen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Use `DocHelper` to simplify your python docstrings\n\nIf you have been writing classes or functions with many shared arguments, you\nmight have going through the tedious and error prone process of copy-pasting,\nsearching-updating same docstring again and again. Passing through `**kwargs`\nmight not always be the solution not to say it's implicit and makes user to\nlook up multiple documents to find available arguments.\n\nSo how about one place to store and update them all? `DocHelper` keeps the\ndocstrings for arguments in the same place and you only need to write the\ntemplate for each class or functions - it will compose and fill in the\ntemplate in Google format.\n\nWorks from Jupyter notebook to Sphinx where docstrings were read by importing.\n\n## Installation\n#### Install using `pip` (recommended)\n\n```bash\npip install doc-helper\n```\n\n#### Install from source\n```bash\n# make sure you have setuptools and wheel installed\n\ngit clone https://github.com/ynshen/DocHelper.git\ncd DocHelper\npython setup.py bdist_wheel\npip install dist/the-wheel-file-of-your-version.whl\n```\n\n## Usage\n\n#### Initialize a `DocHelper` with argument docstrings\n\n```python\nfrom doc_helper import DocHelper\n\nmy_doc = DocHelper(\n    arg1='Just an simple argument',           # defined as keyword arguments\n    arg2=('Also an simple argument'),         # or a (not really) tuple\n    arg3=('int', 'This argument is integer')  # tuple with data type\n)\n```\n\n#### Add arguments when you needed\n```python\nmy_doc.add(\n    arg4=('pd.DataFrame', 'Just a new argument')\n)\n```\n\n#### Use `DocHelper.get()` to get formatted docstring for arguments\n\n```python\n# Pass a list/tuple of argument names to `DocHelper.get()`\n\u003e\u003e\u003e print(my_doc.get(['arg1', 'arg3'], indent_at_top=False))\narg1: Just an simple argument\n    arg3 (int): This argument is integer\n\n# control behavior through `indent`, `indent_at_top`, and `sep`\n\u003e\u003e\u003e print(my_doc.get(['arg1', 'arg3'], indent_at_top=True, indent=8, sep='|\\n'))\n        arg1: Just an simple argument|\n        arg3 (int): This argument is integer\n\n# Pass a callable (function) to automatic find related arguments (except 'self')\ndef awesome_function(arg1, arg3):\n    pass\n\n\u003e\u003e\u003e print(my_doc.get(awesome_function, indent_at_top=True))\n    arg1: Just an simple argument\n    arg3 (int): This argument is integer\n```\n\n\n### Use decorator `DocHelper.compose` to write template\n\nSimply write a string with comma separated arguments name in `\u003c\u003c` and `\u003e\u003e`.\nDefault indents is 4, just add a number to change to desired indents.\n\n```python\n# Example 1\n\n@my_doc.compose(\"\"\"This is my awesome function\nArgs:\n    \u003c\u003carg1, arg2\u003e\u003e\n    arg3: This arg3 is special\n\"\"\")\ndef awesome_function(arg1, arg2, arg3):\n    pass\n \n\u003e\u003e\u003e print(awesome_function.__doc__)\nThis is my awesome function\nArgs:\n    arg1: Just an simple argument\n    arg2: Also an simple argument\n    arg3: This arg3 is special\n\n\n# Example 2\n\n@my_doc.compose(\"\"\"This is another awesome function only takes arg1, arg3, and I want indent = 8\nArgs:\n\u003c\u003carg1, arg2, 8\u003e\u003e\n\"\"\", indent_at_top=True)\ndef another_awesome_function(arg1, arg3):\n    pass\n\n\u003e\u003e\u003e print(another_awesome_function.__doc__)\nThis is another awesome function only takes arg1, arg3, and I wand indent = 8\nArgs:\n        arg1: Just an simple argument\n        arg3 (int): This argument is integer\n\n# Example 3\n\n@my_doc.compose(\"\"\"Feeling lazy? left it blank to include all arguments (except 'self')\nArgs:\n    \u003c\u003c\u003e\u003e\n\"\"\")\ndef another_another_awesome_function(arg1, arg2, arg3):\n    pass\n\n\u003e\u003e\u003e print(another_another_awesome_function.__doc__)\nFeeling lazy? left it blank to include all arguments (except 'self')\nArgs:\n    arg1: Just an simple argument\n    arg2: Also an simple argument\n    arg3 (int): This argument is integer\n\n```\n\n## Update\n- version 1.1.1: indents at the top of `\u003c\u003c  \u003e\u003e` can be controlled through `DocHelper.compose(indent_at_top=False/True)`, default False.\n- version 1.1.0: extra indents at the top of each lines were subtracted\n\n## TODO\n- ~~Add docstring formatting function to subtract extra indents~~\n- Include different formatting (Numpy, reStructuredText)\n\n```\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynshen%2Fdochelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fynshen%2Fdochelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynshen%2Fdochelper/lists"}