.gitattributes 语言学家语言声明

问题描述

我目前正在开发一个小 python 包,整个源代码在我的 git repo 中。我已经看到 github 没有正确跟踪 repo 统计信息中的 cython 文件。所以我刚刚创建了一个 .gitattributes 文件,我找到了其中的文档 here。最后我的文件看起来像这样:

# Specify Python source files. 
*.py linguist-language=python
*.pyi linguist-language=python

# Highlight Cython source files as C language,since it's hopefully better
# than nothing. This also affects repo statistics.
*.pyx linguist-language=C
*.pxd linguist-language=C

# Specify python binary files.
*.db binary
...

# Jupyter notebook
*.ipynb text

# Highlight C and C++ source files.
*.c linguist-language=c
*.cc linguist-language=cpp
*.cxx linguist-language=cpp
...

# Compiled Object files
*.slo binary
...

# Compiled Dynamic libraries
*.so binary
...

声明所有这些扩展是一种常见的做法吗?
是否可以在不让最近的 Python 开发人员心脏病发作的情况下完成*.pyx linguist-language=C

解决方法

请注意,Cython 应被 linguist(GitHub.com 上用于检测 blob 语言的库)识别。

Cython:
  type: programming
  group: Python
  extensions:
  - ".pyx"
  - ".pxd"
  - ".pxi"

Calamitizer/rainbow-of-code 这样的项目确实说明了这一点,并且确实使用了 .gitattributes with

*.pyx linguist-language=Cython