我们在Chromium的代码注释里经常能够看到使用纯ascii字符做的示意图,如下所示:
chrome\browser\ui\views\frame\browser_view.h
// BrowserView layout (LTR one is pictured here).
//
// --------------------------------------------------------------------
// | TopContainerView (top_container_) |
// | -------------------------------------------------------------- |
// | | Tabs (tabstrip_) | |
// | |------------------------------------------------------------| |
// | | Navigation buttons, address bar, menu (toolbar_) | |
// | -------------------------------------------------------------- |
// |------------------------------------------------------------------|
// | All infobars (infobar_container_) [1] |
// |------------------------------------------------------------------|
// | Bookmarks (bookmark_bar_view_) [1] |
// |------------------------------------------------------------------|
// | Contents container (contents_container_) |
// | -------------------------------------------------------------- |
// | | devtools_web_view_ | |
// | |------------------------------------------------------------| |
// | | contents_web_view_ | |
// | -------------------------------------------------------------- |
// |------------------------------------------------------------------|
// | Active downloads (download_shelf_) |
// --------------------------------------------------------------------
components\update_client\background_downloader_win.cc
// Ignoring the suspend/resume issues since this code is not using them, the
// job state machine implemented by BITS is something like this:
//
// Suspended--->Queued--->Connecting---->Transferring--->Transferred
// | ^ | | |
// | | V V | (complete)
// +----------|---------+-----------------+-----+ V
// | | | | Acknowledged
// | V V |
// | Transient Error------->Error |
// | | | |(cancel)
// | +-------+---------+--->-+
// | V |
// | (resume) | |
// +------<----------+ +---->Cancelled
components\update_client\crx_update_item.h
// on-demand on-demand
// +---------------------------> kNew <--------------+-------------+
// | | | |
// | V | |
// | +--------------------> kChecking -<-------+---|---<-----+ |
// | | | | | | |
// | | error V no | | | |
// kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
// ^ | ^
// | yes | |
// | diff=false V |
// | +-----------> kCanUpdate |
// | | | |
// | | V no |
// | | [differential update?]->----+ |
// | | | | |
// | | yes | | |
// | | error V | |
// | +---------<- kDownloadingDiff | |
// | | | | |
// | | | | |
// | | error V | |
// | +---------<- kUpdatingDiff ->--------|-----------+ success
// | | |
// | error V |
// +----------------------------------------- kDownloading |
// | | |
// | error V |
// +------------------------------------------ kUpdating ->----+ success
media\cast\sender\performance_metrics_overlay.h
// This module provides a display of frame-level performance metrics, rendered
// in the lower-right corner of a VideoFrame. It looks like this:
//
// +---------------------------------------------------------------------+
// | @@@@@@@@@@@@@@@@@@@@@@@ |
// | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
// | @@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@ |
// | @@@@@@@@@@@@@ @@@@ |
// | @@@@@@@@@@ @@@@ |
// | @@@@@ @@@ @@@ @@@@ |
// | @@@ @ @@@ @@@@ @@@@ |
// | @@@@ @@@@ @@@@ |
// | @@@@ @@@ @@@ |
// | @@@@ @@ @@@ |
// | @@@@@ @@@ @@@ @@@ |
// | @@@@@ @@@@@ @@@@ @@@@ |
// | @@@@@ @@@@@@@@@@@@@ @@@@ |
// | @@@@@@ @@@@ 1 45% 75% |
// | @@@@@@@@ @@@@@@ 22 400. 4000 |
// | @@@@@@@@@@@@@@@@ 16.7 1280x720 0:15.12 |
// +---------------------------------------------------------------------+
v8\src\compiler\osr.h
// Graphs built for OSR from the AstGraphBuilder are structured as follows:
// Start
// +-------------------^^-----+
// | |
// OsrNormalEntry OsrLoopEntry <-------------+
// | | |
// control flow before loop | A OsrValue
// | | | |
// | +------------------------+ | +-------+
// | | +-------------+ | | +--------+
// | | | | | | | |
// ( Loop )<-----------|------------------ ( phi ) |
// | | |
// loop body | backedge(s) |
// | | | |
// | +--------------+ B <-----+
// |
// end
这些图都是用ascii字符组成的,因此很容易结合在源代码里面,形象的描述了代码的逻辑。
如果自己手动敲出这些ascii图,当然很麻烦了,幸好有这方面的工具帮助我们画出ascii图来。
最方便的是这个http://asciiflow.com/ 在线的网站。此外还有vim的drawit插件。
最后来个皮卡丘的ascii图:
<< ## <<< ### < <<
< ##### < ###### << <<
<<< ###### << ###### <<<<< <<<<<<<
< ******* < ****** < <
<< ********* ******* << < <
<< ********* ****** <<< << << < <<<<
< ****** ********* ***** <<< << < <
<< ******************** < <<<<< <<<<< <
<< ******************** < << <
<< < <<< *********************** < << <<<<<<
< ****###***********###***** < <<
< *****# ###*********# ###***** < <
<< ******#####*********#####****** <
*******###***********##******** <
***##**********#**********##*** ***********************
**####*******************####** **********************
**####*****#***#***#*****####** *********************
<< **##*******###*###*******##** *** ****************
<< <<<<<< ************************* *******************
<< <<< << ******************* ******************
<<< < *********************** ******
************************* ******
*************************** ***********
*****#****************#****** ***********
<< *******#*************#********* ###******** <<<<
<<<<<< *********#**********#********** #### < << <<<<
< **##******#********#****###****########## < <<< <<
<<< << *****#****#********#***#*******########## < <
<<<<< *******####********####********
*****************************