{"id":23693409,"url":"https://github.com/alyetama/openai-auto-docstring-generator","last_synced_at":"2026-05-07T05:33:03.280Z","repository":{"id":116015119,"uuid":"496375181","full_name":"Alyetama/OpenAI-Auto-Docstring-Generator","owner":"Alyetama","description":"Use OpenAI API to automatically generate elaborate, high quality docstring for your Python files","archived":false,"fork":false,"pushed_at":"2022-05-25T20:20:49.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T03:52:21.629Z","etag":null,"topics":["auto-docs","docstring","openai","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alyetama.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-25T20:09:11.000Z","updated_at":"2022-05-25T20:20:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"3099d770-dae3-48bd-9d33-4cda145c44e7","html_url":"https://github.com/Alyetama/OpenAI-Auto-Docstring-Generator","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/Alyetama%2FOpenAI-Auto-Docstring-Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alyetama%2FOpenAI-Auto-Docstring-Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alyetama%2FOpenAI-Auto-Docstring-Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alyetama%2FOpenAI-Auto-Docstring-Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alyetama","download_url":"https://codeload.github.com/Alyetama/OpenAI-Auto-Docstring-Generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758895,"owners_count":19692041,"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":["auto-docs","docstring","openai","python"],"created_at":"2024-12-30T03:52:00.040Z","updated_at":"2026-01-18T20:30:17.558Z","avatar_url":"https://github.com/Alyetama.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI Auto-Docstring Generator\n\nUse OpenAI API to automatically generate elaborate, high quality docstring for your Python files\\*.\n\n[![Supported Python versions](https://img.shields.io/badge/Python-%3E=3.6-blue.svg)](https://www.python.org/downloads/) [![PEP8](https://img.shields.io/badge/Code%20style-PEP%208-orange.svg)](https://www.python.org/dev/peps/pep-0008/) \n\n\\*Not meant to be used in production.\n\n## Getting Started\n\n1. Clone this repository\n\n```sh\ngit clone https://github.com/Alyetama/OpenAI-Auto-Docstring-Generator.git\ncd OpenAI-Auto-Docstring-Generator\n```\n\n2. [Sign up](https://beta.openai.com/signup) or [login](https://beta.openai.com/login/) to OpenAI.\n3. Go to your [API keys page](https://beta.openai.com/account/api-keys).\n4. Create a new secret key and copy it.\n5. In a terminal shell, run:\n\n```sh\nexport OPENAI_TOKEN='xxxxxxxxxxx'\n```\n\n## Usage\n\n```\npython generate_docstring.py --help\n\nusage: generate_docstring.py [-h] -f FILE [-t OPENAI_TOKEN]\n                             [-F FREQUENCY_PENALTY] [-T TOP_P]\n                             [-p PRESENCE_PENALTY] [-e TEMPERATURE]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -f FILE, --file FILE  Path to the input file\n  -t OPENAI_TOKEN, --openai-token OPENAI_TOKEN\n                        OpenAI token\n  -F FREQUENCY_PENALTY, --frequency-penalty FREQUENCY_PENALTY\n                        How much to penalize new tokens based on their\n                        existing frequency in the text so far. Decreases the\n                        model's likelihood to repeat the same line verbatim\n  -T TOP_P, --top-p TOP_P\n                        Controls diversity via nucleus sampling: (e.g., 0.5\n                        means half of all likelihood weighted options are\n                        considered\n  -p PRESENCE_PENALTY, --presence-penalty PRESENCE_PENALTY\n                        How much to penalize new tokens based on whether they\n                        appear in the text so far. Increases the model's\n                        likelihood to talk about new topics\n  -e TEMPERATURE, --temperature TEMPERATURE\n                        Controls randomness (i.e., lowering results in less\n                        random completions. As the temperature approaches\n                        zero, the model will become deterministic and\n                        repetitive\n```\n\n\n### Example\n\n```sh\npython generate_docstring.py -f some_script.py -t \"$OPENAI_TOKEN\"\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eInput file\u003c/summary\u003e\n  \n```python\n\n# Source: https://github.com/Alyetama/Gotipy\n\nimport json\nimport os\nimport sys\nimport traceback\n\nimport requests\nfrom requests.auth import HTTPBasicAuth\nfrom requests.structures import CaseInsensitiveDict\n\nfrom gotipy_exceptions import _MissingRequiredParameter\n\n\nclass Gotify:\n\n    def __init__(self,\n                 host_address=None,\n                 fixed_token=None,\n                 fixed_priority=None):\n        self.host_address = host_address\n        self.fixed_token = fixed_token\n        self.fixed_priority = fixed_priority\n\n    @staticmethod\n    def _headers():\n        headers = CaseInsensitiveDict()\n        headers['Content-type'] = 'application/json'\n        return headers\n\n    def _get_host_address(self):\n        host_address = self.host_address\n        if not host_address and not os.getenv('GOTIFY_HOST_ADDRESS'):\n            raise _MissingRequiredParameter('host_address',\n                                            'GOTIFY_HOST_ADDRESS',\n                                            'class instance')\n        else:\n            if not host_address:\n                host_address = os.getenv('GOTIFY_HOST_ADDRESS')\n        if 'http' not in host_address:\n            raise TypeError(\n                'Missing a valid scheme in the host address (e.g., `http://`)!'\n            )\n        return host_address\n\n    def create_app(self, admin_username, admin_password, app_name, desc=None):\n        host_address = self._get_host_address()\n        url = f'{host_address}/application'\n        data = json.dumps({'name': app_name, 'description': desc})\n        auth = HTTPBasicAuth(admin_username, admin_password)\n        resp = requests.post(url,\n                             headers=self._headers(),\n                             data=data,\n                             auth=auth)\n        return resp.json()\n\n    def push(self, title, message, token=None, priority=2):\n\n        if not token:\n            token = self.fixed_token\n            if not token:\n                token = os.getenv('GOTIFY_APP_TOKEN')\n        host_address = self.host_address\n\n        if self.fixed_priority:\n            priority = self.fixed_priority\n\n        data = {'title': title, 'message': message, 'priority': priority}\n\n        if not token and not os.getenv('GOTIFY_APP_TOKEN'):\n            raise _MissingRequiredParameter('token', 'GOTIFY_APP_TOKEN',\n                                            'method')\n\n        host_address = self._get_host_address()\n\n        url = f'{host_address}/message?token={token}'\n        resp = requests.post(url,\n                             headers=self._headers(),\n                             data=json.dumps(data))\n\n        try:\n            return resp.json()\n        except json.decoder.JSONDecodeError:\n            traceback.print_exception(*sys.exc_info())\n        except requests.exceptions.ConnectionError:\n            traceback.print_exception(*sys.exc_info())\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003eOutput\u003c/summary\u003e\n\n```\n# \u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e METHOD/FUNCTION: __init__ (1/5)\n\n    \"\"\"\n    Args:\n        host_address (str): The host address of the server.\n        fixed_token (str): The fixed token to be used for authentication.\n        fixed_priority (int): The fixed priority to be used for authentication.\n    \"\"\"\n\n--------------------------------------------------------------------------------\n\n# \u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e METHOD/FUNCTION: _headers (2/5)\n\n    \"\"\"\n    Returns:\n        headers (CaseInsensitiveDict): A dictionary of headers to be used in the request.\n    \"\"\"\n\n--------------------------------------------------------------------------------\n\n# \u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e METHOD/FUNCTION: _get_host_address (3/5)\n\n    \"\"\"Gets the host address of the Gotify server.\n\n    Returns:\n        str: The host address of the Gotify server.\n\n    Raises:\n        _MissingRequiredParameter: If the host address is not provided.\n        TypeError: If the host address is not a valid URL.\n    \"\"\"\n\n--------------------------------------------------------------------------------\n\n# \u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e METHOD/FUNCTION: create_app (4/5)\n\n    \"\"\"Creates a new application.\n\n    Args:\n        admin_username (str): The username of the admin user.\n        admin_password (str): The password of the admin user.\n        app_name (str): The name of the application to be created.\n        desc (str): The description of the application to be created.\n\n    Returns:\n        dict: A dictionary containing the response from the server.\n    \"\"\"\n\n--------------------------------------------------------------------------------\n\n# \u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e\u003e METHOD/FUNCTION: push (5/5)\n\n    \"\"\"Sends a push notification to the Gotify server.\n\n    Args:\n        title (str): The title of the notification.\n        message (str): The message of the notification.\n        token (str): The token of the application.\n        priority (int): The priority of the notification.\n\n    Returns:\n        dict: A dictionary containing the response from the server.\n\n    Raises:\n        MissingRequiredParameter: If the token is not provided.\n        ConnectionError: If the connection to the server fails.\n    \"\"\"\n\n--------------------------------------------------------------------------------\n\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falyetama%2Fopenai-auto-docstring-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falyetama%2Fopenai-auto-docstring-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falyetama%2Fopenai-auto-docstring-generator/lists"}