一直在用markdown(不得不說markdown語法真的太強大太簡潔了杭措,效果也太優(yōu)美,沒學(xué)過markdown語法的可以自己學(xué)下)寫東西互例,知道用markdown可以畫出來很性感的流程圖舔糖,遂決定學(xué)下如何用markdown來畫流程圖愈犹。
代碼
flow
st=>start: Start
op=>operation: Your Operation
cond=>condition: Yes or No?
e=>end
st->op->cond
cond(yes)->e
cond(no)->op
效果
深度截圖20160909223653.png
說明
這樣幾行簡單的代碼就生成了一個優(yōu)雅的流程圖。
流程圖大致分為兩段阻荒,第一段是定義元素挠锥,第二段是定義元素之間的走向。
定義元素的語法
tag=>type: content:>url
- tag就是元素名字侨赡,
- type是這個元素的類型蓖租,有6中類型,分別為:
start # 開始
end # 結(jié)束
operation # 操作
subroutine # 子程序
condition # 條件
inputoutput # 輸入或產(chǎn)出
content就是在框框中要寫的內(nèi)容羊壹,注意type后的冒號與文本之間一定要有個空格蓖宦。
url是一個連接,與框框中的文本相綁定
連接元素的語法
用->來連接兩個元素舶掖,需要注意的是condition類型球昨,因為他有yes和no兩個分支,所以要寫成
c2(yes)->io->e
c2(no)->op2->e
實際應(yīng)用
下邊獻上我的拙作眨攘,這是一個爬取某網(wǎng)站的商品評論數(shù)據(jù)主慰,然后進行情感分析的小項目嚣州,有四個模塊:獲取待爬取商品id,爬取代理共螺,爬取評論该肴,情感分析
代碼
flow
st=>start: Start|past:>http://www.google.com[blank]
e=>end: End:>http://www.google.com
op1=>operation: get_hotel_ids|past
op2=>operation: get_proxy|current
sub1=>subroutine: get_proxy|current
op3=>operation: save_comment|current
op4=>operation: set_sentiment|current
op5=>operation: set_record|current
cond1=>condition: ids_remain空?
cond2=>condition: proxy_list空?
cond3=>condition: ids_got空?
cond4=>condition: 爬取成功??
cond5=>condition: ids_remain空?
io1=>inputoutput: ids-remain
io2=>inputoutput: proxy_list
io3=>inputoutput: ids-got
st->op1(right)->io1->cond1
cond1(yes)->sub1->io2->cond2
cond2(no)->op3
cond2(yes)->sub1
cond1(no)->op3->cond4
cond4(yes)->io3->cond3
cond4(no)->io1
cond3(no)->op4
cond3(yes, right)->cond5
cond5(yes)->op5
cond5(no)->cond3
op5->e
效果
流程圖.png
這個流程圖有個問題,我希望ids_remain的兩個條件都為空藐不,但是markdown語法沒法實現(xiàn)我這需求(不知道我這需求是不是有毛苍群濉),只能先這樣畫著了雏蛮。
原文
http://jlan.me/2016/09/09/%E7%94%A8markdown%E6%9D%A5%E7%94%BB%E6%B5%81%E7%A8%8B%E5%9B%BE/