效果展示
示例項目位址: https://github.com/mouday/chinesename 擷取第一個徽章 build
build
在項目主目錄下建立三個必要檔案
建立
.travis.yml
,寫明
python的版本号、需要安裝的依賴和測試子產品
language: python
python:
- "3.6"
install:
- pip install -r requirements.txt
script:
- pytest
requirements.txt
,寫清依賴版本
chinesename==0.0.9
test_chinesename.py
寫pytest測試用例
pytest參考:
https://www.jianshu.com/p/c5037bed334adef test_chinesename():
pass
将代碼送出到github
用github賬号登入:
https://travis-ci.org/找到剛剛送出的項目,添加到travis,然後就會自動測試,
測試通過後,點選圖示,選擇markdown格式,複制粘貼到README.md檔案
送出代碼就可以看到效果了
擷取pypi徽章
前提,先送出項目到pypi
可參考:Python程式設計:twine子產品打包python項目上傳pypi
打開網站:
https://shields.io/#/examples/version找到pypi,點選後填入link和image畫線部分資訊,就可以看到圖示版本已經變成pypi對應的版本了
複制markdown連結,粘貼到README.md檔案,再次送出代碼,效果就出來了
自定義小徽章
如果覺得上面擷取徽章的方式比較麻煩,那麼就自定義小徽章
打開往下滑
https://shields.io/填入對應的資訊,選擇樣式後,點選make,然後就出現了一個圖,csnd支援按照markdown的格式引用
例如:
[![CSDN](https://img.shields.io/badge/CSND-%E5%BD%AD%E4%B8%96%E7%91%9C-brightgreen.svg)](https://blog.csdn.net/mouday)
參考:
文檔:
https://docs.travis-ci.com/user/languages/python/