贡献
🌐 Contributing
🐛 如何报告错误
🌐 🐛 How to report a bug
请备注
🌐 Please note
Turf 的高级结构正在 #1428 讨论中。目前(2018 年 6 月),已部分转换为 Typescript,贡献文档并未完全反映当前状态。
🌐 The high-level structure of Turf is undergoing discussion at #1428. Currently (June 2018), there is a partial conversion to Typescript, and the contribution documentation does not completely reflect the current status.
如何贡献
🌐 How To Contribute
- 大部分工作发生在子模块中。这些子模块位于
packages目录下,前缀为“turf-”。 - 如果你想提出新功能,请在 Turfjs/turf 中提交一个问题。
- 始终包含测试。我们使用 tape。
- Turf 模块很小,只包含一个导出函数。
- GeoJSON 是 Turf 的通用语言。任何可以表示为地理的东西都应该使用它作为数据结构。
- 不惜一切代价避免过度依赖。
- 草皮用于各种地方。确保你的代码可以在浏览器中运行(即:不要调用外部服务,不要访问文件系统,等等)。
packages/turf-<module>中的README.md文件是从index.js的 JSDocs 自动生成的。请修改 JSDocs,而不是直接修改README.md文件。然后通过执行./scripts/generate-readmes或在 TurfJS 根目录运行npm run docs来更新/创建README.md。- 最后从项目根文件夹运行
npm test来运行部署项目所需的所有测试。
代码风格
🌐 Code Style
为了确保代码风格,请在 turf 根目录下运行
🌐 To ensure code style, at the turf root level run
$ npm run lint
- 遵循 AirBNB JavaScript 代码风格。
- Turf 的目标是在合理的情况下使用 ES5 特性。我们不使用 ES6 特性。
Turf 模块结构
🌐 Structure of a turf module
turf-<MODULE NAME>
│ index.js
│ index.d.ts
│ bench.js
│ test.js
│ types.ts
│ package.json
│ README.md
│ LICENSE
│
└───test
│
├───in
│ points.geojson
│
└───out
points.geojson
要开始使用新模块,请导航至根目录并运行
🌐 To get started with a new module navigate to the root directory and run
$ node ./scripts/create-new-module <MODULE NAME>
它将在 packages 内创建一个新文件夹,其中包含你的模块的简单模板。
🌐 it will create a new folder inside packages with a simple boilerplate for your module.
index.js- 该文件按顺序包含了你需要导入的各个模块、JSDocs 文档,以及模块提供的单个导出函数。有关文档中支持的类型的更多信息,请参见…index.d.ts- 这是一个描述你函数签名的 TypeScript 文件。有关 TypeScript 支持的类型的更多信息,请参见…bench.js- 此文件使用 Benchmark 来计时你的函数。test.js- 此文件包含你的 tape 测试。我们更喜欢从放置在./test/in的 GeoJSON 文件构建的动态测试,如果你的REGEN环境变量已设置 为true,则会随后写入./test/out。如果REGEN设置为其他值,则运行npm t会将测试输出与已存在于./test/out的文件进行比较。types.ts- 列出在index.d.ts中使用的自定义 TypeScript 类型的文件。package.json- node 元数据容器文件。在index.js中导入的模块应列在此处的dependencies下,而在test.js和/或bench.js中使用的模块应列在devDependencies下。npm install会查看此文件以在./node_modules中安装依赖。README.md- 这个自述文件是通过在项目根目录运行npm rundocs自动 生成的。不要编辑此文件。LICENCE- 与 README 文件一样,此文件不可编辑。test/- 该目录包含提供动态测试数据(在./test/in中)和测试结果(在./test/out中)使用的 GeoJSON 文件。./test/out中的文件 不应 手动编辑。它们应通过将环境变量 设置REGEN为true来动态生成,然后通过将REGEN设置为其他值来将测试与这些文件进行比较。生成的输出文件可以拖放到 geojson.io 中,以直观地查看模块是否正常运行。
发布
🌐 Publishing
安装 lerna:
🌐 Install lerna:
$ npm install -g lerna@2.0.0-beta.34
发布测试版本:
🌐 Publish a test release:
$ lerna publish --canary
文档
🌐 Documentation
要更新 TurfJS 的文档(README.md),请使用以下 npm run docs:
🌐 To update TurfJS's Documentation (README.md) use the following npm run docs:
- 在模块内: 将只生成该模块的文档。
- 主文件夹: 将为所有模块生成文档。
示例
🌐 Examples
仅为 @turf/center 构建文档
$ cd ./turf/packages/turf-center
$ npm run docs
> @turf/center@5.0.4 docs /Users/mac/Github/turf/packages/turf-center
> node ../../scripts/generate-readmes
Building Docs: @turf/center
为所有模块构建文档
$ cd ./turf
$ npm run docs
> @5.0.0 docs /Users/mac/Github/turf
> node ./scripts/generate-readmes
Building Docs: @turf/along
Building Docs: @turf/area
Building Docs: @turf/bbox-clip
Building Docs: @turf/bbox-polygon
Building Docs: @turf/bbox
Building Docs: @turf/bearing
Building Docs: @turf/bezier-spline
Building Docs: @turf/boolean-clockwise
....
其他依赖
🌐 Other Dependencies
- Turf 在测试、打包和发布过程中使用 Yarn 和 lerna。
- 当你在根目录运行
npm install时,Lerna 将会被自动安装。 - 你的计算机上需要安装 Yarn,安装程序可通过 Yarn 网站获取。
- 当你在根目录运行
资金 贡献
🌐 Financial contributions
我们也欢迎在我们的 open collective 上完全透明的财务捐款。任何人都可以提交开支。如果开支对社区的发展有意义,它将由核心贡献者在我们的 open collective 的账本中“合并”,提交开支的人将获得报销。
🌐 We also welcome financial contributions in full transparency on our open collective. Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.