Skip to content

Outdated code examples in docstrings #40

@NoahTheDuke

Description

@NoahTheDuke

When transitioning the readme and examples from the old syntax extension to the PPX style in f545de6, none of the docstrings were updated, so they all reference and give code examples using the old bitmatch syntax:

{[
let display pkt =
bitmatch pkt with
(* IPv4 packet header
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 4 | IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*)
| { 4 : 4; hdrlen : 4; tos : 8; length : 16;
identification : 16; flags : 3; fragoffset : 13;
ttl : 8; protocol : 8; checksum : 16;
source : 32;
dest : 32;
options : (hdrlen-5)*32 : bitstring;
payload : -1 : bitstring } ->
printf "IPv4:\n";
printf " header length: %d * 32 bit words\n" hdrlen;
printf " type of service: %d\n" tos;
printf " packet length: %d bytes\n" length;
printf " identification: %d\n" identification;
printf " flags: %d\n" flags;
printf " fragment offset: %d\n" fragoffset;
printf " ttl: %d\n" ttl;
printf " protocol: %d\n" protocol;
printf " checksum: %d\n" checksum;
printf " source: %lx dest: %lx\n" source dest;
printf " header options + padding:\n";
Bitstring.hexdump_bitstring stdout options;
printf " packet payload:\n";
Bitstring.hexdump_bitstring stdout payload
| { version : 4 } ->
eprintf "unknown IP version %d\n" version;
exit 1
| { _ } as pkt ->
eprintf "data is smaller than one nibble:\n";
Bitstring.hexdump_bitstring stderr pkt;
exit 1
]}

As a new user of the library, it would be helpful if the documentation matched the current syntax.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions