mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.81k stars 6.65k forks source link

In Packet drawings, allow bit count as well as start-end #5978

Open BryanCrotazGivEnergy opened 1 month ago

BryanCrotazGivEnergy commented 1 month ago

Proposal

Mermaid packet format insists on bit start -> bit end. This makes it very difficult to change your mind while generating a packet diagram, eg increasing one field from 16-32 bit.

As well as supporting <s>-<e>: "name" where s is the start bit and e is the end bit

Also support <s>-<b>bits: "name" <s>-1bit: "name" where s is the start bit, b is a bit count

Short form is the most valuable <b>bits: "name" follows on automatically from the previous bit. If this is the first field, it's assumed to start at bit 0.

Example

```mermaid 8bits: "Message Id" 16bits: "From Id" 32bits: "Command Data" 1bit: "write flag" 7bits: "reserved" 64-8bits: "new data" ```

Screenshots

No response

zanedp commented 1 week ago

I was considering using the "packet" type as a way to draw a memory map, which would be byte-scale instead of bit-scale. I wonder if a different syntax that didn't "tie" the diagram to a particular unit of measure would be more flexible? Shorting to b would make it so both "bits" and "bytes" make sense. But maybe doing something like +5 to mean it's relative to the previous thing would work and be intuitive?

+16: Header
+32: Data
+4: Footer

Using + is similar to "relative time" in PlantUML's timing diagram.