Metadata-Version: 2.4
Name: srcdocgen
Version: 0.1.0
Summary: Generate software copyright source-code materials from Git repositories.
License: MIT License
        
        Copyright (c) 2026 MengYX
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: pygments>=2.19.0
Requires-Dist: python-docx>=1.1.2
Requires-Dist: reportlab>=4.2.5
Requires-Dist: textual>=1.0.0
Description-Content-Type: text/markdown

# srcdocgen

软著源代码材料生成器。第一版提供可安装的 Python CLI/TUI 骨架，从 Git 仓库扫描被跟踪源码，剥离注释和空行，按模板给出文件纳入建议，并导出：

- `source-code.pdf`
- `source-code.docx`
- `manifest.json`

## 安装与运行

完整使用流程见 [使用指南](docs/USER_GUIDE.md)。

```bash
pipx run srcdocgen --help
uv run srcdocgen --help
uv run srcdocgen init-config --repo ./project --template python --software-name "示例系统" --software-version "V1.0"
uv run srcdocgen --repo ./project
uv run srcdocgen generate --repo ./project --template python --out-dir ./softdoc
```

默认配置文件是目标仓库根目录下的 `srcdocgen.toml`。

## 生成规则

- 文件列表来自 `git ls-files`，不会修改目标仓库。
- 自动排除依赖目录、构建产物、测试文件、Markdown 文档、纯文本、数据文件、配置文件、规则文件、字体二进制、版本/依赖锁定文件、文件头带生成标记的文件和常见生成代码。
- 使用 Pygments token 剥离注释，避免误删字符串、URL、正则中的注释符号。
- PDF 使用 A4 页面、等宽字体、默认每页 50 行、共 60 页；短项目按实际行数生成页数。
- PDF 和 DOCX 页眉左侧会输出软件名称、版本号，右侧会输出 `current / total` 格式页码，页眉和正文之间带横线。
- 当过滤后源码不足 3000 行时，生成全部可纳入源码并提示建议上传全部源代码；不会补空、不伪造代码。
- 当源码超过 3000 行时，按 PRD 取前 30 页连续源码和后 30 页连续源码。
- PDF 在缺少系统 CJK 字体时会使用内置 Noto Sans Mono CJK SC fallback；字体来源记录在 `srcdocgen/assets/fonts/SOURCE.json`。

## 模板

内置模板：`android`、`ios`、`web`、`node`、`python`、`java`、`go`、`generic`。

配置项支持软件名称、版本号、模板、包含/排除 glob、业务关键词、风险关键词、单文件最大行数、脱敏开关、页数和每页行数。

## License

MIT License. See [LICENSE](LICENSE).
