From 1a20f0d0b35dd8aa05f783d0660e87a014000dc8 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 30 Jan 2020 01:21:20 -0800 Subject: [PATCH] Link to tracking issues from BEP support table type: documentation --- README.md | 124 ++++++++++++++++---------------- bin/update-readme/src/opt.rs | 59 +++++++++++---- bin/update-readme/src/status.rs | 65 +++++++++++++---- 3 files changed, 160 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index eb198c8..7f30004 100644 --- a/README.md +++ b/README.md @@ -52,66 +52,66 @@ To force colored output, pass `--use-color always` on the command line. ### BEP Support -| Symbol | Meaning | -|--------------------|----------------| -| :white_check_mark: | Supported | -| :x: | Unsupported | -| :heavy_minus_sign: | Not Applicable | +| Symbol | Meaning | +|--------------------|---------------------------------------| +| :white_check_mark: | Supported | +| :x: | Unsupported (links to tracking issue) | +| :heavy_minus_sign: | Not Applicable | -| BEP | Status | Title | -|:----------------------------------------------:|:------------------:|:-----------------------------------------------------------------| -| [00](http://bittorrent.org/beps/bep_0000.html) | :heavy_minus_sign: | Index of BitTorrent Enhancement Proposals | -| [01](http://bittorrent.org/beps/bep_0001.html) | :heavy_minus_sign: | The BitTorrent Enhancement Proposal Process | -| [02](http://bittorrent.org/beps/bep_0002.html) | :heavy_minus_sign: | Sample reStructured Text BEP Template | -| [03](http://bittorrent.org/beps/bep_0003.html) | :white_check_mark: | The BitTorrent Protocol Specification | -| [04](http://bittorrent.org/beps/bep_0004.html) | :heavy_minus_sign: | Assigned Numbers | -| [05](http://bittorrent.org/beps/bep_0005.html) | :x: | DHT Protocol | -| [06](http://bittorrent.org/beps/bep_0006.html) | :heavy_minus_sign: | Fast Extension | -| [07](http://bittorrent.org/beps/bep_0007.html) | :heavy_minus_sign: | IPv6 Tracker Extension | -| [08](http://bittorrent.org/beps/bep_0008.html) | :heavy_minus_sign: | Tracker Peer Obfuscation | -| [09](http://bittorrent.org/beps/bep_0009.html) | :x: | Extension for Peers to Send Metadata Files | -| [10](http://bittorrent.org/beps/bep_0010.html) | :heavy_minus_sign: | Extension Protocol | -| [11](http://bittorrent.org/beps/bep_0011.html) | :heavy_minus_sign: | Peer Exchange (PEX) | -| [12](http://bittorrent.org/beps/bep_0012.html) | :white_check_mark: | Multitracker Metadata Extension | -| [14](http://bittorrent.org/beps/bep_0014.html) | :heavy_minus_sign: | Local Service Discovery | -| [15](http://bittorrent.org/beps/bep_0015.html) | :heavy_minus_sign: | UDP Tracker Protocol for BitTorrent | -| [16](http://bittorrent.org/beps/bep_0016.html) | :heavy_minus_sign: | Superseeding | -| [17](http://bittorrent.org/beps/bep_0017.html) | :x: | HTTP Seeding | -| [18](http://bittorrent.org/beps/bep_0018.html) | :heavy_minus_sign: | Search Engine Specificiation | -| [19](http://bittorrent.org/beps/bep_0019.html) | :x: | WebSeed - HTTP/FTP Seeding (GetRight style) | -| [20](http://bittorrent.org/beps/bep_0020.html) | :heavy_minus_sign: | Peer ID Conventions | -| [21](http://bittorrent.org/beps/bep_0021.html) | :heavy_minus_sign: | Extension for partial seeds | -| [22](http://bittorrent.org/beps/bep_0022.html) | :heavy_minus_sign: | BitTorrent Local Tracker Discovery Protocol | -| [23](http://bittorrent.org/beps/bep_0023.html) | :heavy_minus_sign: | Tracker Returns Compact Peer Lists | -| [24](http://bittorrent.org/beps/bep_0024.html) | :heavy_minus_sign: | Tracker Returns External IP | -| [25](http://bittorrent.org/beps/bep_0025.html) | :heavy_minus_sign: | An Alternate BitTorrent Cache Discovery Protocol | -| [26](http://bittorrent.org/beps/bep_0026.html) | :heavy_minus_sign: | Zeroconf Peer Advertising and Discovery | -| [27](http://bittorrent.org/beps/bep_0027.html) | :white_check_mark: | Private Torrents | -| [28](http://bittorrent.org/beps/bep_0028.html) | :heavy_minus_sign: | Tracker exchange extension | -| [29](http://bittorrent.org/beps/bep_0029.html) | :heavy_minus_sign: | uTorrent transport protocol | -| [30](http://bittorrent.org/beps/bep_0030.html) | :x: | Merkle hash torrent extension | -| [31](http://bittorrent.org/beps/bep_0031.html) | :heavy_minus_sign: | Failure Retry Extension | -| [32](http://bittorrent.org/beps/bep_0032.html) | :heavy_minus_sign: | BitTorrent DHT Extensions for IPv6 | -| [33](http://bittorrent.org/beps/bep_0033.html) | :heavy_minus_sign: | DHT Scrapes | -| [34](http://bittorrent.org/beps/bep_0034.html) | :x: | DNS Tracker Preferences | -| [35](http://bittorrent.org/beps/bep_0035.html) | :x: | Torrent Signing | -| [36](http://bittorrent.org/beps/bep_0036.html) | :x: | Torrent RSS feeds | -| [37](http://bittorrent.org/beps/bep_0037.html) | :heavy_minus_sign: | Anonymous BitTorrent over proxies | -| [38](http://bittorrent.org/beps/bep_0038.html) | :x: | Finding Local Data Via Torrent File Hints | -| [39](http://bittorrent.org/beps/bep_0039.html) | :x: | Updating Torrents Via Feed URL | -| [40](http://bittorrent.org/beps/bep_0040.html) | :heavy_minus_sign: | Canonical Peer Priority | -| [41](http://bittorrent.org/beps/bep_0041.html) | :x: | UDP Tracker Protocol Extensions | -| [42](http://bittorrent.org/beps/bep_0042.html) | :heavy_minus_sign: | DHT Security extension | -| [43](http://bittorrent.org/beps/bep_0043.html) | :heavy_minus_sign: | Read-only DHT Nodes | -| [44](http://bittorrent.org/beps/bep_0044.html) | :x: | Storing arbitrary data in the DHT | -| [45](http://bittorrent.org/beps/bep_0045.html) | :x: | Multiple-address operation for the BitTorrent DHT | -| [46](http://bittorrent.org/beps/bep_0046.html) | :x: | Updating Torrents Via DHT Mutable Items | -| [47](http://bittorrent.org/beps/bep_0047.html) | :x: | Padding files and extended file attributes | -| [48](http://bittorrent.org/beps/bep_0048.html) | :x: | Tracker Protocol Extension: Scrape | -| [49](http://bittorrent.org/beps/bep_0049.html) | :x: | Distributed Torrent Feeds | -| [50](http://bittorrent.org/beps/bep_0050.html) | :heavy_minus_sign: | Publish/Subscribe Protocol | -| [51](http://bittorrent.org/beps/bep_0051.html) | :heavy_minus_sign: | DHT Infohash Indexing | -| [52](http://bittorrent.org/beps/bep_0052.html) | :x: | The BitTorrent Protocol Specification v2 | -| [53](http://bittorrent.org/beps/bep_0053.html) | :x: | Magnet URI extension - Select specific file indices for download | -| [54](http://bittorrent.org/beps/bep_0054.html) | :heavy_minus_sign: | The lt_donthave extension | -| [55](http://bittorrent.org/beps/bep_0055.html) | :heavy_minus_sign: | Holepunch extension | +| BEP | Status | Title | +|:----------------------------------------------:|:-----------------------------------------------------:|:-----------------------------------------------------------------| +| [00](http://bittorrent.org/beps/bep_0000.html) | :heavy_minus_sign: | Index of BitTorrent Enhancement Proposals | +| [01](http://bittorrent.org/beps/bep_0001.html) | :heavy_minus_sign: | The BitTorrent Enhancement Proposal Process | +| [02](http://bittorrent.org/beps/bep_0002.html) | :heavy_minus_sign: | Sample reStructured Text BEP Template | +| [03](http://bittorrent.org/beps/bep_0003.html) | :white_check_mark: | The BitTorrent Protocol Specification | +| [04](http://bittorrent.org/beps/bep_0004.html) | :heavy_minus_sign: | Assigned Numbers | +| [05](http://bittorrent.org/beps/bep_0005.html) | [:x:](https://github.com/casey/intermodal/issues/90) | DHT Protocol | +| [06](http://bittorrent.org/beps/bep_0006.html) | :heavy_minus_sign: | Fast Extension | +| [07](http://bittorrent.org/beps/bep_0007.html) | :heavy_minus_sign: | IPv6 Tracker Extension | +| [08](http://bittorrent.org/beps/bep_0008.html) | :heavy_minus_sign: | Tracker Peer Obfuscation | +| [09](http://bittorrent.org/beps/bep_0009.html) | [:x:](https://github.com/casey/intermodal/issues/91) | Extension for Peers to Send Metadata Files | +| [10](http://bittorrent.org/beps/bep_0010.html) | :heavy_minus_sign: | Extension Protocol | +| [11](http://bittorrent.org/beps/bep_0011.html) | :heavy_minus_sign: | Peer Exchange (PEX) | +| [12](http://bittorrent.org/beps/bep_0012.html) | :white_check_mark: | Multitracker Metadata Extension | +| [14](http://bittorrent.org/beps/bep_0014.html) | :heavy_minus_sign: | Local Service Discovery | +| [15](http://bittorrent.org/beps/bep_0015.html) | :heavy_minus_sign: | UDP Tracker Protocol for BitTorrent | +| [16](http://bittorrent.org/beps/bep_0016.html) | :heavy_minus_sign: | Superseeding | +| [17](http://bittorrent.org/beps/bep_0017.html) | [:x:](https://github.com/casey/intermodal/issues/92) | HTTP Seeding | +| [18](http://bittorrent.org/beps/bep_0018.html) | :heavy_minus_sign: | Search Engine Specificiation | +| [19](http://bittorrent.org/beps/bep_0019.html) | [:x:](https://github.com/casey/intermodal/issues/93) | WebSeed - HTTP/FTP Seeding (GetRight style) | +| [20](http://bittorrent.org/beps/bep_0020.html) | :heavy_minus_sign: | Peer ID Conventions | +| [21](http://bittorrent.org/beps/bep_0021.html) | :heavy_minus_sign: | Extension for partial seeds | +| [22](http://bittorrent.org/beps/bep_0022.html) | :heavy_minus_sign: | BitTorrent Local Tracker Discovery Protocol | +| [23](http://bittorrent.org/beps/bep_0023.html) | :heavy_minus_sign: | Tracker Returns Compact Peer Lists | +| [24](http://bittorrent.org/beps/bep_0024.html) | :heavy_minus_sign: | Tracker Returns External IP | +| [25](http://bittorrent.org/beps/bep_0025.html) | :heavy_minus_sign: | An Alternate BitTorrent Cache Discovery Protocol | +| [26](http://bittorrent.org/beps/bep_0026.html) | :heavy_minus_sign: | Zeroconf Peer Advertising and Discovery | +| [27](http://bittorrent.org/beps/bep_0027.html) | :white_check_mark: | Private Torrents | +| [28](http://bittorrent.org/beps/bep_0028.html) | :heavy_minus_sign: | Tracker exchange extension | +| [29](http://bittorrent.org/beps/bep_0029.html) | :heavy_minus_sign: | uTorrent transport protocol | +| [30](http://bittorrent.org/beps/bep_0030.html) | [:x:](https://github.com/casey/intermodal/issues/94) | Merkle hash torrent extension | +| [31](http://bittorrent.org/beps/bep_0031.html) | :heavy_minus_sign: | Failure Retry Extension | +| [32](http://bittorrent.org/beps/bep_0032.html) | :heavy_minus_sign: | BitTorrent DHT Extensions for IPv6 | +| [33](http://bittorrent.org/beps/bep_0033.html) | :heavy_minus_sign: | DHT Scrapes | +| [34](http://bittorrent.org/beps/bep_0034.html) | :heavy_minus_sign: | DNS Tracker Preferences | +| [35](http://bittorrent.org/beps/bep_0035.html) | [:x:](https://github.com/casey/intermodal/issues/96) | Torrent Signing | +| [36](http://bittorrent.org/beps/bep_0036.html) | :heavy_minus_sign: | Torrent RSS feeds | +| [37](http://bittorrent.org/beps/bep_0037.html) | :heavy_minus_sign: | Anonymous BitTorrent over proxies | +| [38](http://bittorrent.org/beps/bep_0038.html) | :heavy_minus_sign: | Finding Local Data Via Torrent File Hints | +| [39](http://bittorrent.org/beps/bep_0039.html) | [:x:](https://github.com/casey/intermodal/issues/98) | Updating Torrents Via Feed URL | +| [40](http://bittorrent.org/beps/bep_0040.html) | :heavy_minus_sign: | Canonical Peer Priority | +| [41](http://bittorrent.org/beps/bep_0041.html) | [:x:](https://github.com/casey/intermodal/issues/97) | UDP Tracker Protocol Extensions | +| [42](http://bittorrent.org/beps/bep_0042.html) | :heavy_minus_sign: | DHT Security extension | +| [43](http://bittorrent.org/beps/bep_0043.html) | :heavy_minus_sign: | Read-only DHT Nodes | +| [44](http://bittorrent.org/beps/bep_0044.html) | :heavy_minus_sign: | Storing arbitrary data in the DHT | +| [45](http://bittorrent.org/beps/bep_0045.html) | :heavy_minus_sign: | Multiple-address operation for the BitTorrent DHT | +| [46](http://bittorrent.org/beps/bep_0046.html) | :heavy_minus_sign: | Updating Torrents Via DHT Mutable Items | +| [47](http://bittorrent.org/beps/bep_0047.html) | [:x:](https://github.com/casey/intermodal/issues/99) | Padding files and extended file attributes | +| [48](http://bittorrent.org/beps/bep_0048.html) | :heavy_minus_sign: | Tracker Protocol Extension: Scrape | +| [49](http://bittorrent.org/beps/bep_0049.html) | [:x:](https://github.com/casey/intermodal/issues/100) | Distributed Torrent Feeds | +| [50](http://bittorrent.org/beps/bep_0050.html) | :heavy_minus_sign: | Publish/Subscribe Protocol | +| [51](http://bittorrent.org/beps/bep_0051.html) | :heavy_minus_sign: | DHT Infohash Indexing | +| [52](http://bittorrent.org/beps/bep_0052.html) | [:x:](https://github.com/casey/intermodal/issues/101) | The BitTorrent Protocol Specification v2 | +| [53](http://bittorrent.org/beps/bep_0053.html) | :heavy_minus_sign: | Magnet URI extension - Select specific file indices for download | +| [54](http://bittorrent.org/beps/bep_0054.html) | :heavy_minus_sign: | The lt_donthave extension | +| [55](http://bittorrent.org/beps/bep_0055.html) | :heavy_minus_sign: | Holepunch extension | diff --git a/bin/update-readme/src/opt.rs b/bin/update-readme/src/opt.rs index 2e29756..cf10f66 100644 --- a/bin/update-readme/src/opt.rs +++ b/bin/update-readme/src/opt.rs @@ -149,31 +149,62 @@ impl Opt { assert_eq!(originals.len(), beps.len()); + let mut width = (0, 0, 0); + + let rows = beps + .into_iter() + .zip(originals) + .map(|(bep, original)| { + assert_eq!(bep.number, original.number); + + let row = ( + format!( + "[{:02}](http://bittorrent.org/beps/bep_{:04}.html)", + bep.number, bep.number + ), + original.status.to_string(), + bep.title, + ); + + width.0 = width.0.max(row.0.len()); + width.1 = width.1.max(row.1.len()); + width.2 = width.2.max(row.2.len()); + + row + }) + .collect::>(); + let mut lines = Vec::new(); - let width = beps.iter().map(|bep| bep.title.len()).max().unwrap_or(0); - lines.push(format!( - "| BEP | Status | {:width$} |", + "| {:w0$} | {:w1$} | {:w2$} |", + "BEP", + "Status", "Title", - width = width + w0 = width.0, + w1 = width.1, + w2 = width.2, )); lines.push(format!( - "|:----------------------------------------------:|:------------------:|:{:- }, } impl FromStr for Status { type Err = String; fn from_str(text: &str) -> Result { - match text.replace('\\', "").as_str() { - "x" => Ok(Self::NotSupported), - "+" => Ok(Self::Supported), - "-" => Ok(Self::NotApplicable), - "?" => Ok(Self::Unknown), - ":x:" => Ok(Self::NotSupported), - ":white_check_mark:" => Ok(Self::Supported), - ":heavy_minus_sign:" => Ok(Self::NotApplicable), - ":grey_question:" => Ok(Self::Unknown), - _ => Err(format!("invalid status: {}", text)), + let error = || format!("invalid status: {}", text); + + let unescaped = text.replace('\\', ""); + + let (emoji, tracking_issue) = if !unescaped.starts_with('[') { + (text, None) + } else { + let status_pattern = Regex::new( + r"(?x) + ^ + \[ + (?P:[a-zA-Z0-9]+:) + \] + \( + https://github.com/casey/intermodal/issues/(?P[0-9]+) + \) + $ + ", + ) + .unwrap(); + + let captures = status_pattern.captures(&unescaped).ok_or_else(error)?; + + let emoji = captures.name("emoji").unwrap().as_str(); + + let tracking_issue = captures + .name("tracking_issue") + .map(|text| text.as_str().parse::().unwrap()); + + (emoji, tracking_issue) + }; + + match emoji { + "x" => Ok(Status::NotSupported { tracking_issue }), + "+" => Ok(Status::Supported), + "-" => Ok(Status::NotApplicable), + "?" => Ok(Status::Unknown), + ":x:" => Ok(Status::NotSupported { tracking_issue }), + ":white_check_mark:" => Ok(Status::Supported), + ":heavy_minus_sign:" => Ok(Status::NotApplicable), + ":grey_question:" => Ok(Status::Unknown), + _ => Err(error()), } } } @@ -31,7 +63,16 @@ impl Display for Status { Self::Unknown => write!(f, ":grey_question:"), Self::NotApplicable => write!(f, ":heavy_minus_sign:"), Self::Supported => write!(f, ":white_check_mark:"), - Self::NotSupported => write!(f, ":x:"), + Self::NotSupported { + tracking_issue: None, + } => write!(f, ":x:"), + Self::NotSupported { + tracking_issue: Some(number), + } => write!( + f, + "[:x:](https://github.com/casey/intermodal/issues/{})", + number + ), } } }