codesigs 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codesigs-0.0.1/LICENSE +201 -0
- codesigs-0.0.1/MANIFEST.in +5 -0
- codesigs-0.0.1/PKG-INFO +121 -0
- codesigs-0.0.1/README.md +84 -0
- codesigs-0.0.1/codesigs/__init__.py +2 -0
- codesigs-0.0.1/codesigs/_modidx.py +24 -0
- codesigs-0.0.1/codesigs/core.py +147 -0
- codesigs-0.0.1/codesigs.egg-info/PKG-INFO +121 -0
- codesigs-0.0.1/codesigs.egg-info/SOURCES.txt +16 -0
- codesigs-0.0.1/codesigs.egg-info/dependency_links.txt +1 -0
- codesigs-0.0.1/codesigs.egg-info/entry_points.txt +2 -0
- codesigs-0.0.1/codesigs.egg-info/not-zip-safe +1 -0
- codesigs-0.0.1/codesigs.egg-info/requires.txt +4 -0
- codesigs-0.0.1/codesigs.egg-info/top_level.txt +1 -0
- codesigs-0.0.1/pyproject.toml +11 -0
- codesigs-0.0.1/settings.ini +46 -0
- codesigs-0.0.1/setup.cfg +4 -0
- codesigs-0.0.1/setup.py +63 -0
codesigs-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
codesigs-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codesigs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Extract function and method signatures from source code across multiple languages.
|
|
5
|
+
Home-page: https://github.com/AnswerDotAI/codesigs
|
|
6
|
+
Author: Jeremy Howard
|
|
7
|
+
Author-email: github@jhoward.fastmail.fm
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Keywords: nbdev jupyter notebook python
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: fastcore
|
|
22
|
+
Requires-Dist: ast-grep-py
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: description-content-type
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: keywords
|
|
31
|
+
Dynamic: license
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: provides-extra
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
37
|
+
|
|
38
|
+
# codesigs
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
42
|
+
|
|
43
|
+
## About `codesigs`
|
|
44
|
+
|
|
45
|
+
`codesigs` extracts function and method signatures from source code
|
|
46
|
+
across over a dozen programming languages. It uses
|
|
47
|
+
[ast-grep](https://ast-grep.github.io/) for most languages and Python’s
|
|
48
|
+
built-in `ast` module for Python files, providing accurate syntax-aware
|
|
49
|
+
parsing rather than brittle regex matching.
|
|
50
|
+
|
|
51
|
+
This is useful for:
|
|
52
|
+
|
|
53
|
+
- **Documentation generation** - quickly summarize the public API of a
|
|
54
|
+
codebase
|
|
55
|
+
- **Code search and navigation** - find functions by signature pattern
|
|
56
|
+
- **LLM context preparation** - provide compact API summaries to
|
|
57
|
+
language models without including full implementations
|
|
58
|
+
- **Codebase analysis** - understand the structure of unfamiliar
|
|
59
|
+
projects
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install latest from [pypi](https://pypi.org/project/codesigs/)
|
|
64
|
+
|
|
65
|
+
``` sh
|
|
66
|
+
$ pip install codesigs
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## How to use
|
|
70
|
+
|
|
71
|
+
Pass source code to a language-specific function to get a list of
|
|
72
|
+
signatures:
|
|
73
|
+
|
|
74
|
+
``` python
|
|
75
|
+
sigs = py_sigs("""
|
|
76
|
+
def greet(name, age=10):
|
|
77
|
+
"Say hello to someone"
|
|
78
|
+
return f"Hello {name}, you are {age}"
|
|
79
|
+
|
|
80
|
+
class Calculator:
|
|
81
|
+
def add(self, a, b):
|
|
82
|
+
return a + b
|
|
83
|
+
""")
|
|
84
|
+
for o in sigs: print(o)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
def greet(name, age=10):
|
|
88
|
+
"Say hello to someone" ...
|
|
89
|
+
class Calculator: ...
|
|
90
|
+
def add(self, a, b): ...
|
|
91
|
+
|
|
92
|
+
Use
|
|
93
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)
|
|
94
|
+
when you have source code and know the file extension:
|
|
95
|
+
|
|
96
|
+
``` python
|
|
97
|
+
ext_sigs("function greet(name) { return `Hello ${name}`; }", ".js")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
['function greet(name) {...}']
|
|
101
|
+
|
|
102
|
+
Or use
|
|
103
|
+
[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
104
|
+
to read and extract signatures from a file in one step:
|
|
105
|
+
|
|
106
|
+
``` python
|
|
107
|
+
file_sigs('../codesigs/core.py')[:3]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
['def get_docstring(node, lines):\n "Get docstring from source lines if present" ...',
|
|
111
|
+
'def _node_sig(node, lines): ...',
|
|
112
|
+
'def py_sigs(src):\n "Extract class/function/method signatures from Python source" ...']
|
|
113
|
+
|
|
114
|
+
The package supports Python, JavaScript/TypeScript, Java, Rust, C#, CSS,
|
|
115
|
+
Go, Ruby, PHP, Kotlin, Swift, and Lua. Each language has a dedicated
|
|
116
|
+
function
|
|
117
|
+
(e.g. [`js_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#js_sigs),
|
|
118
|
+
[`rust_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#rust_sigs)),
|
|
119
|
+
or use
|
|
120
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)/[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
121
|
+
which auto-detect from the extension.
|
codesigs-0.0.1/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# codesigs
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
|
+
|
|
6
|
+
## About `codesigs`
|
|
7
|
+
|
|
8
|
+
`codesigs` extracts function and method signatures from source code
|
|
9
|
+
across over a dozen programming languages. It uses
|
|
10
|
+
[ast-grep](https://ast-grep.github.io/) for most languages and Python’s
|
|
11
|
+
built-in `ast` module for Python files, providing accurate syntax-aware
|
|
12
|
+
parsing rather than brittle regex matching.
|
|
13
|
+
|
|
14
|
+
This is useful for:
|
|
15
|
+
|
|
16
|
+
- **Documentation generation** - quickly summarize the public API of a
|
|
17
|
+
codebase
|
|
18
|
+
- **Code search and navigation** - find functions by signature pattern
|
|
19
|
+
- **LLM context preparation** - provide compact API summaries to
|
|
20
|
+
language models without including full implementations
|
|
21
|
+
- **Codebase analysis** - understand the structure of unfamiliar
|
|
22
|
+
projects
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install latest from [pypi](https://pypi.org/project/codesigs/)
|
|
27
|
+
|
|
28
|
+
``` sh
|
|
29
|
+
$ pip install codesigs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## How to use
|
|
33
|
+
|
|
34
|
+
Pass source code to a language-specific function to get a list of
|
|
35
|
+
signatures:
|
|
36
|
+
|
|
37
|
+
``` python
|
|
38
|
+
sigs = py_sigs("""
|
|
39
|
+
def greet(name, age=10):
|
|
40
|
+
"Say hello to someone"
|
|
41
|
+
return f"Hello {name}, you are {age}"
|
|
42
|
+
|
|
43
|
+
class Calculator:
|
|
44
|
+
def add(self, a, b):
|
|
45
|
+
return a + b
|
|
46
|
+
""")
|
|
47
|
+
for o in sigs: print(o)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
def greet(name, age=10):
|
|
51
|
+
"Say hello to someone" ...
|
|
52
|
+
class Calculator: ...
|
|
53
|
+
def add(self, a, b): ...
|
|
54
|
+
|
|
55
|
+
Use
|
|
56
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)
|
|
57
|
+
when you have source code and know the file extension:
|
|
58
|
+
|
|
59
|
+
``` python
|
|
60
|
+
ext_sigs("function greet(name) { return `Hello ${name}`; }", ".js")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
['function greet(name) {...}']
|
|
64
|
+
|
|
65
|
+
Or use
|
|
66
|
+
[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
67
|
+
to read and extract signatures from a file in one step:
|
|
68
|
+
|
|
69
|
+
``` python
|
|
70
|
+
file_sigs('../codesigs/core.py')[:3]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
['def get_docstring(node, lines):\n "Get docstring from source lines if present" ...',
|
|
74
|
+
'def _node_sig(node, lines): ...',
|
|
75
|
+
'def py_sigs(src):\n "Extract class/function/method signatures from Python source" ...']
|
|
76
|
+
|
|
77
|
+
The package supports Python, JavaScript/TypeScript, Java, Rust, C#, CSS,
|
|
78
|
+
Go, Ruby, PHP, Kotlin, Swift, and Lua. Each language has a dedicated
|
|
79
|
+
function
|
|
80
|
+
(e.g. [`js_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#js_sigs),
|
|
81
|
+
[`rust_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#rust_sigs)),
|
|
82
|
+
or use
|
|
83
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)/[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
84
|
+
which auto-detect from the extension.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Autogenerated by nbdev
|
|
2
|
+
|
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
|
4
|
+
'doc_baseurl': '/codesigs',
|
|
5
|
+
'doc_host': 'https://AnswerDotAI.github.io',
|
|
6
|
+
'git_url': 'https://github.com/AnswerDotAI/codesigs',
|
|
7
|
+
'lib_path': 'codesigs'},
|
|
8
|
+
'syms': { 'codesigs.core': { 'codesigs.core._get_sigs': ('core.html#_get_sigs', 'codesigs/core.py'),
|
|
9
|
+
'codesigs.core._node_sig': ('core.html#_node_sig', 'codesigs/core.py'),
|
|
10
|
+
'codesigs.core.csharp_sigs': ('core.html#csharp_sigs', 'codesigs/core.py'),
|
|
11
|
+
'codesigs.core.css_selectors': ('core.html#css_selectors', 'codesigs/core.py'),
|
|
12
|
+
'codesigs.core.ext_sigs': ('core.html#ext_sigs', 'codesigs/core.py'),
|
|
13
|
+
'codesigs.core.file_sigs': ('core.html#file_sigs', 'codesigs/core.py'),
|
|
14
|
+
'codesigs.core.get_docstring': ('core.html#get_docstring', 'codesigs/core.py'),
|
|
15
|
+
'codesigs.core.go_sigs': ('core.html#go_sigs', 'codesigs/core.py'),
|
|
16
|
+
'codesigs.core.java_sigs': ('core.html#java_sigs', 'codesigs/core.py'),
|
|
17
|
+
'codesigs.core.js_sigs': ('core.html#js_sigs', 'codesigs/core.py'),
|
|
18
|
+
'codesigs.core.kotlin_sigs': ('core.html#kotlin_sigs', 'codesigs/core.py'),
|
|
19
|
+
'codesigs.core.lua_sigs': ('core.html#lua_sigs', 'codesigs/core.py'),
|
|
20
|
+
'codesigs.core.php_sigs': ('core.html#php_sigs', 'codesigs/core.py'),
|
|
21
|
+
'codesigs.core.py_sigs': ('core.html#py_sigs', 'codesigs/core.py'),
|
|
22
|
+
'codesigs.core.ruby_sigs': ('core.html#ruby_sigs', 'codesigs/core.py'),
|
|
23
|
+
'codesigs.core.rust_sigs': ('core.html#rust_sigs', 'codesigs/core.py'),
|
|
24
|
+
'codesigs.core.swift_sigs': ('core.html#swift_sigs', 'codesigs/core.py')}}}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
2
|
+
|
|
3
|
+
# %% auto #0
|
|
4
|
+
__all__ = ['get_docstring', 'py_sigs', 'js_sigs', 'java_sigs', 'rust_sigs', 'csharp_sigs', 'css_selectors', 'go_sigs',
|
|
5
|
+
'kotlin_sigs', 'swift_sigs', 'lua_sigs', 'php_sigs', 'ruby_sigs', 'ext_sigs', 'file_sigs']
|
|
6
|
+
|
|
7
|
+
# %% ../nbs/00_core.ipynb #033c76fd
|
|
8
|
+
from fastcore.utils import *
|
|
9
|
+
from fastcore.meta import delegates
|
|
10
|
+
from ast_grep_py import SgRoot
|
|
11
|
+
|
|
12
|
+
import ast
|
|
13
|
+
|
|
14
|
+
# %% ../nbs/00_core.ipynb #8b98c134
|
|
15
|
+
def get_docstring(node, lines):
|
|
16
|
+
"Get docstring from source lines if present"
|
|
17
|
+
if not (node.body and isinstance(node.body[0], ast.Expr) and isinstance(node.body[0].value, ast.Constant)): return None
|
|
18
|
+
doc_node = node.body[0]
|
|
19
|
+
return '\n'.join(lines[doc_node.lineno-1:doc_node.end_lineno])
|
|
20
|
+
|
|
21
|
+
def _node_sig(node, lines):
|
|
22
|
+
body_start = max(node.body[0].lineno - 1, node.lineno)
|
|
23
|
+
sig = '\n'.join(lines[node.lineno-1:body_start])
|
|
24
|
+
doc = get_docstring(node, lines)
|
|
25
|
+
return (f"{sig}\n{doc}" if doc else sig).strip('\r\n') + ' ...'
|
|
26
|
+
|
|
27
|
+
def py_sigs(src):
|
|
28
|
+
"Extract class/function/method signatures from Python source"
|
|
29
|
+
tree,lines = ast.parse(src),src.splitlines()
|
|
30
|
+
def _collect(nodes):
|
|
31
|
+
sigs = []
|
|
32
|
+
for n in nodes:
|
|
33
|
+
if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
34
|
+
sigs.append(_node_sig(n, lines))
|
|
35
|
+
sigs.extend(_collect(n.body))
|
|
36
|
+
return sigs
|
|
37
|
+
return _collect(tree.body)
|
|
38
|
+
|
|
39
|
+
# %% ../nbs/00_core.ipynb #5c60cc8c
|
|
40
|
+
def _get_sigs(src, lang, kinds, name_kind, params_kind, fmt):
|
|
41
|
+
root = SgRoot(src, lang).root()
|
|
42
|
+
sigs = []
|
|
43
|
+
for kind in kinds:
|
|
44
|
+
for n in root.find_all(kind=kind):
|
|
45
|
+
name,params = n.find(kind=name_kind),n.find(kind=params_kind)
|
|
46
|
+
if name and params: sigs.append(fmt(n, name.text(), params.text()))
|
|
47
|
+
return sigs
|
|
48
|
+
|
|
49
|
+
# %% ../nbs/00_core.ipynb #ea058abf
|
|
50
|
+
def js_sigs(src, lang="javascript"):
|
|
51
|
+
"Extract function signatures from JS/TS source"
|
|
52
|
+
sigs = _get_sigs(src, lang, ["function_declaration"], "identifier", "formal_parameters",
|
|
53
|
+
lambda n,nm,ps: f"function {nm}{ps} {{...}}")
|
|
54
|
+
sigs += _get_sigs(src, lang, ["method_definition"], "property_identifier", "formal_parameters",
|
|
55
|
+
lambda n,nm,ps: f"{nm}{ps} {{...}}")
|
|
56
|
+
return sigs
|
|
57
|
+
|
|
58
|
+
# %% ../nbs/00_core.ipynb #d175e1f3
|
|
59
|
+
def java_sigs(src):
|
|
60
|
+
"Extract method signatures from Java source"
|
|
61
|
+
def fmt(n, nm, ps):
|
|
62
|
+
typ = n.find(kind="type_identifier") or n.find(kind="void_type") or n.find(kind="integral_type")
|
|
63
|
+
return f"{typ.text() if typ else 'void'} {nm}{ps};"
|
|
64
|
+
return _get_sigs(src, "java", ["method_declaration"], "identifier", "formal_parameters", fmt)
|
|
65
|
+
|
|
66
|
+
# %% ../nbs/00_core.ipynb #4492b94d
|
|
67
|
+
def rust_sigs(src):
|
|
68
|
+
"Extract function signatures from Rust source"
|
|
69
|
+
return _get_sigs(src, "rust", ["function_item"], "identifier", "parameters",
|
|
70
|
+
lambda n,nm,ps: f"fn {nm}{ps} {{...}}")
|
|
71
|
+
|
|
72
|
+
# %% ../nbs/00_core.ipynb #db15d753
|
|
73
|
+
def csharp_sigs(src):
|
|
74
|
+
"Extract method signatures from C# source"
|
|
75
|
+
def fmt(n, nm, ps):
|
|
76
|
+
typ = n.find(kind="predefined_type") or n.find(kind="identifier")
|
|
77
|
+
return f"{typ.text() if typ else 'void'} {nm}{ps};"
|
|
78
|
+
return _get_sigs(src, "csharp", ["method_declaration"], "identifier", "parameter_list", fmt)
|
|
79
|
+
|
|
80
|
+
# %% ../nbs/00_core.ipynb #62eb97fb
|
|
81
|
+
def css_selectors(src):
|
|
82
|
+
"Extract CSS selectors from source"
|
|
83
|
+
root = SgRoot(src, "css").root()
|
|
84
|
+
return [f"{n.text()} {{...}}" for n in root.find_all(kind="selectors")]
|
|
85
|
+
|
|
86
|
+
# %% ../nbs/00_core.ipynb #148e8adb
|
|
87
|
+
def go_sigs(src):
|
|
88
|
+
"Extract function signatures from Go source"
|
|
89
|
+
root = SgRoot(src, "go").root()
|
|
90
|
+
sigs = []
|
|
91
|
+
for n in root.find_all(kind="function_declaration"):
|
|
92
|
+
name,params = n.find(kind="identifier"),n.find(kind="parameter_list")
|
|
93
|
+
if name and params: sigs.append(f"func {name.text()}{params.text()} {{...}}")
|
|
94
|
+
for n in root.find_all(kind="method_declaration"):
|
|
95
|
+
recv,name = n.find(kind="parameter_list"),n.find(kind="field_identifier")
|
|
96
|
+
params = n.find_all(kind="parameter_list")
|
|
97
|
+
if name and len(params) > 1: sigs.append(f"func {recv.text()} {name.text()}{params[1].text()} {{...}}")
|
|
98
|
+
return sigs
|
|
99
|
+
|
|
100
|
+
# %% ../nbs/00_core.ipynb #ac7ea6f5
|
|
101
|
+
def kotlin_sigs(src):
|
|
102
|
+
"Extract function signatures from Kotlin source"
|
|
103
|
+
return _get_sigs(src, "kotlin", ["function_declaration"], "simple_identifier", "function_value_parameters",
|
|
104
|
+
lambda n,nm,ps: f"fun {nm}{ps} {{...}}")
|
|
105
|
+
|
|
106
|
+
# %% ../nbs/00_core.ipynb #a6ee3031
|
|
107
|
+
def swift_sigs(src):
|
|
108
|
+
"Extract function signatures from Swift source"
|
|
109
|
+
return _get_sigs(src, "swift", ["function_declaration"], "simple_identifier", "parameter",
|
|
110
|
+
lambda n,nm,ps: f"func {nm}({ps}) {{...}}")
|
|
111
|
+
|
|
112
|
+
# %% ../nbs/00_core.ipynb #726f9ab9
|
|
113
|
+
def lua_sigs(src):
|
|
114
|
+
"Extract function signatures from Lua source"
|
|
115
|
+
return _get_sigs(src, "lua", ["function_declaration"], "identifier", "parameters",
|
|
116
|
+
lambda n,nm,ps: f"function {nm}{ps} ... end")
|
|
117
|
+
|
|
118
|
+
# %% ../nbs/00_core.ipynb #94cad5be
|
|
119
|
+
def php_sigs(src):
|
|
120
|
+
"Extract function signatures from PHP source"
|
|
121
|
+
return _get_sigs(src, "php", ["function_definition", "method_declaration"], "name", "formal_parameters",
|
|
122
|
+
lambda n,nm,ps: f"function {nm}{ps} {{...}}")
|
|
123
|
+
|
|
124
|
+
# %% ../nbs/00_core.ipynb #11cdf226
|
|
125
|
+
def ruby_sigs(src):
|
|
126
|
+
"Extract method signatures from Ruby source"
|
|
127
|
+
return _get_sigs(src, "ruby", ["method"], "identifier", "method_parameters",
|
|
128
|
+
lambda n,nm,ps: f"def {nm}{ps} ... end")
|
|
129
|
+
|
|
130
|
+
# %% ../nbs/00_core.ipynb #f58e9a0e
|
|
131
|
+
_sigs_fns = {'.py': py_sigs, '.js': js_sigs, '.ts': lambda s: js_sigs(s, "typescript"), '.jsx': js_sigs,
|
|
132
|
+
'.tsx': lambda s: js_sigs(s, "typescript"), '.java': java_sigs, '.rs': rust_sigs,
|
|
133
|
+
'.cs': csharp_sigs, '.css': css_selectors, '.go': go_sigs, '.rb': ruby_sigs,
|
|
134
|
+
'.php': php_sigs, '.kt': kotlin_sigs, '.kts': kotlin_sigs, '.swift': swift_sigs, '.lua': lua_sigs}
|
|
135
|
+
|
|
136
|
+
# %% ../nbs/00_core.ipynb #6244c5c8
|
|
137
|
+
def ext_sigs(src, ext):
|
|
138
|
+
"Read retrieve signatures for `src` based on suitable langage for `ext`"
|
|
139
|
+
if not ext.startswith('.'): ext = '.'+ext
|
|
140
|
+
fn = _sigs_fns.get(ext)
|
|
141
|
+
return [] if fn is None else fn(src)
|
|
142
|
+
|
|
143
|
+
# %% ../nbs/00_core.ipynb #69100796
|
|
144
|
+
def file_sigs(fname):
|
|
145
|
+
"Read file content and retrieve signatures"
|
|
146
|
+
fname = Path(fname).expanduser()
|
|
147
|
+
return ext_sigs(fname.read_text(), fname.suffix)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codesigs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Extract function and method signatures from source code across multiple languages.
|
|
5
|
+
Home-page: https://github.com/AnswerDotAI/codesigs
|
|
6
|
+
Author: Jeremy Howard
|
|
7
|
+
Author-email: github@jhoward.fastmail.fm
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Keywords: nbdev jupyter notebook python
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: fastcore
|
|
22
|
+
Requires-Dist: ast-grep-py
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: description-content-type
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: keywords
|
|
31
|
+
Dynamic: license
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: provides-extra
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
37
|
+
|
|
38
|
+
# codesigs
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
42
|
+
|
|
43
|
+
## About `codesigs`
|
|
44
|
+
|
|
45
|
+
`codesigs` extracts function and method signatures from source code
|
|
46
|
+
across over a dozen programming languages. It uses
|
|
47
|
+
[ast-grep](https://ast-grep.github.io/) for most languages and Python’s
|
|
48
|
+
built-in `ast` module for Python files, providing accurate syntax-aware
|
|
49
|
+
parsing rather than brittle regex matching.
|
|
50
|
+
|
|
51
|
+
This is useful for:
|
|
52
|
+
|
|
53
|
+
- **Documentation generation** - quickly summarize the public API of a
|
|
54
|
+
codebase
|
|
55
|
+
- **Code search and navigation** - find functions by signature pattern
|
|
56
|
+
- **LLM context preparation** - provide compact API summaries to
|
|
57
|
+
language models without including full implementations
|
|
58
|
+
- **Codebase analysis** - understand the structure of unfamiliar
|
|
59
|
+
projects
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install latest from [pypi](https://pypi.org/project/codesigs/)
|
|
64
|
+
|
|
65
|
+
``` sh
|
|
66
|
+
$ pip install codesigs
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## How to use
|
|
70
|
+
|
|
71
|
+
Pass source code to a language-specific function to get a list of
|
|
72
|
+
signatures:
|
|
73
|
+
|
|
74
|
+
``` python
|
|
75
|
+
sigs = py_sigs("""
|
|
76
|
+
def greet(name, age=10):
|
|
77
|
+
"Say hello to someone"
|
|
78
|
+
return f"Hello {name}, you are {age}"
|
|
79
|
+
|
|
80
|
+
class Calculator:
|
|
81
|
+
def add(self, a, b):
|
|
82
|
+
return a + b
|
|
83
|
+
""")
|
|
84
|
+
for o in sigs: print(o)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
def greet(name, age=10):
|
|
88
|
+
"Say hello to someone" ...
|
|
89
|
+
class Calculator: ...
|
|
90
|
+
def add(self, a, b): ...
|
|
91
|
+
|
|
92
|
+
Use
|
|
93
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)
|
|
94
|
+
when you have source code and know the file extension:
|
|
95
|
+
|
|
96
|
+
``` python
|
|
97
|
+
ext_sigs("function greet(name) { return `Hello ${name}`; }", ".js")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
['function greet(name) {...}']
|
|
101
|
+
|
|
102
|
+
Or use
|
|
103
|
+
[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
104
|
+
to read and extract signatures from a file in one step:
|
|
105
|
+
|
|
106
|
+
``` python
|
|
107
|
+
file_sigs('../codesigs/core.py')[:3]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
['def get_docstring(node, lines):\n "Get docstring from source lines if present" ...',
|
|
111
|
+
'def _node_sig(node, lines): ...',
|
|
112
|
+
'def py_sigs(src):\n "Extract class/function/method signatures from Python source" ...']
|
|
113
|
+
|
|
114
|
+
The package supports Python, JavaScript/TypeScript, Java, Rust, C#, CSS,
|
|
115
|
+
Go, Ruby, PHP, Kotlin, Swift, and Lua. Each language has a dedicated
|
|
116
|
+
function
|
|
117
|
+
(e.g. [`js_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#js_sigs),
|
|
118
|
+
[`rust_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#rust_sigs)),
|
|
119
|
+
or use
|
|
120
|
+
[`ext_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#ext_sigs)/[`file_sigs`](https://AnswerDotAI.github.io/codesigs/core.html#file_sigs)
|
|
121
|
+
which auto-detect from the extension.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
settings.ini
|
|
6
|
+
setup.py
|
|
7
|
+
codesigs/__init__.py
|
|
8
|
+
codesigs/_modidx.py
|
|
9
|
+
codesigs/core.py
|
|
10
|
+
codesigs.egg-info/PKG-INFO
|
|
11
|
+
codesigs.egg-info/SOURCES.txt
|
|
12
|
+
codesigs.egg-info/dependency_links.txt
|
|
13
|
+
codesigs.egg-info/entry_points.txt
|
|
14
|
+
codesigs.egg-info/not-zip-safe
|
|
15
|
+
codesigs.egg-info/requires.txt
|
|
16
|
+
codesigs.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
codesigs
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name="codesigs"
|
|
7
|
+
requires-python=">=3.9"
|
|
8
|
+
dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"]
|
|
9
|
+
|
|
10
|
+
[tool.uv]
|
|
11
|
+
cache-keys = [{ file = "pyproject.toml" }, { file = "settings.ini" }, { file = "setup.py" }]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[DEFAULT]
|
|
2
|
+
# All sections below are required unless otherwise specified.
|
|
3
|
+
# See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
|
|
4
|
+
|
|
5
|
+
### Python library ###
|
|
6
|
+
repo = codesigs
|
|
7
|
+
lib_name = %(repo)s
|
|
8
|
+
version = 0.0.1
|
|
9
|
+
min_python = 3.9
|
|
10
|
+
license = apache2
|
|
11
|
+
black_formatting = False
|
|
12
|
+
requirements = fastcore ast-grep-py
|
|
13
|
+
|
|
14
|
+
### nbdev ###
|
|
15
|
+
doc_path = _docs
|
|
16
|
+
lib_path = codesigs
|
|
17
|
+
nbs_path = nbs
|
|
18
|
+
recursive = True
|
|
19
|
+
tst_flags = notest
|
|
20
|
+
put_version_in_init = True
|
|
21
|
+
update_pyproject = True
|
|
22
|
+
|
|
23
|
+
### Docs ###
|
|
24
|
+
branch = main
|
|
25
|
+
custom_sidebar = False
|
|
26
|
+
doc_host = https://%(user)s.github.io
|
|
27
|
+
doc_baseurl = /%(repo)s
|
|
28
|
+
git_url = https://github.com/%(user)s/%(repo)s
|
|
29
|
+
title = %(lib_name)s
|
|
30
|
+
|
|
31
|
+
### PyPI ###
|
|
32
|
+
audience = Developers
|
|
33
|
+
author = Jeremy Howard
|
|
34
|
+
author_email = github@jhoward.fastmail.fm
|
|
35
|
+
copyright = 2026 onwards, %(author)s
|
|
36
|
+
description = Extract function and method signatures from source code across multiple languages.
|
|
37
|
+
keywords = nbdev jupyter notebook python
|
|
38
|
+
language = English
|
|
39
|
+
status = 3
|
|
40
|
+
user = AnswerDotAI
|
|
41
|
+
|
|
42
|
+
### Optional ###
|
|
43
|
+
# dev_requirements =
|
|
44
|
+
# console_scripts =
|
|
45
|
+
# conda_user =
|
|
46
|
+
# package_data =
|
codesigs-0.0.1/setup.cfg
ADDED
codesigs-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from pkg_resources import parse_version
|
|
2
|
+
from configparser import ConfigParser
|
|
3
|
+
import setuptools, shlex
|
|
4
|
+
assert parse_version(setuptools.__version__)>=parse_version('36.2')
|
|
5
|
+
|
|
6
|
+
# note: all settings are in settings.ini; edit there, not here
|
|
7
|
+
config = ConfigParser(delimiters=['='])
|
|
8
|
+
config.read('settings.ini', encoding='utf-8')
|
|
9
|
+
cfg = config['DEFAULT']
|
|
10
|
+
|
|
11
|
+
cfg_keys = 'version description keywords author author_email'.split()
|
|
12
|
+
expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
|
|
13
|
+
for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
|
|
14
|
+
setup_cfg = {o:cfg[o] for o in cfg_keys}
|
|
15
|
+
|
|
16
|
+
licenses = {
|
|
17
|
+
'apache2': 'Apache-2.0',
|
|
18
|
+
'mit': 'MIT',
|
|
19
|
+
'gpl2': 'GPL-2.0-only',
|
|
20
|
+
'gpl3': 'GPL-3.0-or-later',
|
|
21
|
+
'bsd3': 'BSD-3-Clause',
|
|
22
|
+
}
|
|
23
|
+
statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
|
|
24
|
+
'4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
|
|
25
|
+
py_versions = '3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13'.split()
|
|
26
|
+
|
|
27
|
+
requirements = shlex.split(cfg.get('requirements', ''))
|
|
28
|
+
if cfg.get('pip_requirements'): requirements += shlex.split(cfg.get('pip_requirements', ''))
|
|
29
|
+
min_python = cfg['min_python']
|
|
30
|
+
dev_requirements = (cfg.get('dev_requirements') or '').split()
|
|
31
|
+
|
|
32
|
+
package_data = dict()
|
|
33
|
+
pkg_data = cfg.get('package_data', None)
|
|
34
|
+
if pkg_data:
|
|
35
|
+
package_data[cfg['lib_name']] = pkg_data.split() # split as multiple files might be listed
|
|
36
|
+
# Add package data to setup_cfg for setuptools.setup(..., **setup_cfg)
|
|
37
|
+
setup_cfg['package_data'] = package_data
|
|
38
|
+
|
|
39
|
+
setuptools.setup(
|
|
40
|
+
name = cfg['lib_name'],
|
|
41
|
+
license = licenses.get(cfg['license'].lower(), cfg['license']),
|
|
42
|
+
classifiers = [
|
|
43
|
+
'Development Status :: ' + statuses[int(cfg['status'])],
|
|
44
|
+
'Intended Audience :: ' + cfg['audience'].title(),
|
|
45
|
+
'Natural Language :: ' + cfg['language'].title(),
|
|
46
|
+
] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]],
|
|
47
|
+
url = cfg['git_url'],
|
|
48
|
+
packages = setuptools.find_packages(),
|
|
49
|
+
include_package_data = True,
|
|
50
|
+
install_requires = requirements,
|
|
51
|
+
extras_require={ 'dev': dev_requirements },
|
|
52
|
+
dependency_links = cfg.get('dep_links','').split(),
|
|
53
|
+
python_requires = '>=' + cfg['min_python'],
|
|
54
|
+
long_description = open('README.md', encoding='utf-8').read(),
|
|
55
|
+
long_description_content_type = 'text/markdown',
|
|
56
|
+
zip_safe = False,
|
|
57
|
+
entry_points = {
|
|
58
|
+
'console_scripts': cfg.get('console_scripts','').split(),
|
|
59
|
+
'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d']
|
|
60
|
+
},
|
|
61
|
+
**setup_cfg)
|
|
62
|
+
|
|
63
|
+
|