{"id":15707105,"url":"https://github.com/virtuald/header2whatever","last_synced_at":"2025-09-11T09:39:01.547Z","repository":{"id":27832612,"uuid":"115315013","full_name":"virtuald/header2whatever","owner":"virtuald","description":"Generate arbitrary files from C/C++ header files","archived":false,"fork":false,"pushed_at":"2022-12-05T03:24:56.000Z","size":122,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-12T19:46:37.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/virtuald.png","metadata":{"files":{"readme":"README.rst","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":"2017-12-25T07:04:58.000Z","updated_at":"2024-07-26T06:48:28.000Z","dependencies_parsed_at":"2023-01-14T07:34:40.271Z","dependency_job_id":null,"html_url":"https://github.com/virtuald/header2whatever","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/virtuald/header2whatever","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtuald%2Fheader2whatever","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtuald%2Fheader2whatever/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtuald%2Fheader2whatever/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtuald%2Fheader2whatever/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtuald","download_url":"https://codeload.github.com/virtuald/header2whatever/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtuald%2Fheader2whatever/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259301677,"owners_count":22836976,"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":[],"created_at":"2024-10-03T20:36:38.665Z","updated_at":"2025-06-11T17:03:34.207Z","avatar_url":"https://github.com/virtuald.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"header2whatever (h2w)\n=====================\n\nGenerate arbitrary files from C/C++ header files using CppHeaderParser to read\nthe input files and Jinja2 templates to generate the outputs.\n\nThis grew out of a desire to generate pybind11 wrapping code from C++ header\nfiles. pybind11gen was created, but then I wanted to generate more things...\n\nThere are still rough edges, and the documentation is mostly nonexistent, but\npull requests with fixes/improvements are very welcome!\n\nAs of 0.3.0, h2w requires Python 3.3+\n\nInstall\n-------\n\n::\n\n    pip install header2whatever\n\nUsage\n=====\n\nFirst, you need to create a jinja2 template that represents whatever you want\nto generate from the header file. For example, maybe you want to describe the\nfunctions in yaml::\n\n    ---\n    {% for header in headers %}\n    {% for fn in header.functions %}\n    {{ fn.name }}:\n      returns: {{ fn.returns }}\n      params:\n      {% for param in fn.parameters %}\n      - { name: {{ param.name }}, type: \"{{ param.type }}\" }\n      {% endfor %}\n\n    {% endfor %}\n    {% endfor %}\n\nAnd let's say you have the following header file ``foo.h``::\n\n    void some_fn(int i);\n    int returns_int(int p1, char* p2);\n\nYou can execute the following::\n\n    h2w foo.h -o foo.yml\n\nAnd you'll get the following output::\n\n    ---\n    returns_int:\n      returns: int\n      params:\n      - { name: p1, type: \"int\" }\n      - { name: p2, type: \"char *\" }\n\n    some_fn:\n      returns: void\n      params:\n      - { name: i, type: \"int\" }\n\nAs you can see, while this is a silly example, this approach is very flexible\nand fairly powerful.\n\nCurrently, the data structure passed to the template isn't documented -- but\nit's a filtered version of whatever CppHeaderParser outputs when it parses a\nheader.\n\nSee the examples folder for more examples.\n\nBatch mode\n----------\n\nIf you need to process multiple files, or just want to record the parameters for\nautogenerating a file without writing a shell script, batch mode is useful. You\npass two parameters: a yaml file with the configuration, and an output directory\nto write the files to.\n\n\nUsing data from external sources\n--------------------------------\n\nSometimes you want to mix in data that CppHeaderParser can't give you. If you\npass the ``--yaml`` option, it will load the yaml into a dictionary and make it\navailable to the template as the 'data' variable.\n\nYou can also pass key=value parameters via the ``--param`` option, and\nthe specified keys will be available to the template.\n\nCustom processing\n-----------------\n\nWhen you need to do more complex logic that a jinja2 template just isn't\nappropriate for, you can specify a python file to load custom hooks from.\n\nSee [the default hooks](header2whatever/default_hooks.py) for documentation.\n\nLicense\n=======\n\nApache 2\n\nAuthor\n======\n\nDustin Spicuzza (dustin@virtualroadside.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtuald%2Fheader2whatever","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtuald%2Fheader2whatever","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtuald%2Fheader2whatever/lists"}