Zero One Blog Forum Development

Menu tree generator


I need to generate tons of menu trees like this. Drawing manually in Photoshop is VERY boring.

I found this tool https://markmap.js.org/repl Which almost completely meets my needs. No additional code for markup except markdown.

But I need a little rework this tool, so this code renders into the picture above.

# Main header

## Subheader

- Simple item
- Hello
- One more
- Complex iitem
	- sub item
    - one more
    	- Lol
        - kek
        - cheburek
    - third

## Item 2

- Some item
- Easy item
- Much more
	- sub item
    - one more
    	- Lol
        - kek
        - cheburek
    - third

## Item 3

- links
- **inline** ~~text~~ *styles*
- multiline
  text
- `inline code`
-
    ```js
    console.log('code block');
    // Multiline code
    Hello
    ```
- MathJax - `\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)`
One more line in one item

Please help with this task, if you can.

UPD:

First PoC made by @horcicaa https://github.com/Flipper-Zero/flipper-menu-generator

2 Likes

https://graphviz.org/

Examples here https://graphviz.org/gallery/

3 Likes

http://mimind.cryptobees.com/

I would recommend this specific python wrapper. If you familiar with python it’s much easier to start than learn a new DSL (DOT). DOT is not hard but python is more convenient because often you need to generate/preprocess data for graph programmatically. (instead of making graph for one specific data)

https://graphviz.readthedocs.io/

Mermaid diagrams: https://mermaid-js.github.io/mermaid/

Some samples:

```mermaid
 classDiagram
      Human -- |> Govno
      Human -- |> Mocha
      Human -- |> Privet
      Human: secret
      class Human {
         Kakatb
         Pisatb
         govoritb
      }
      class Govno {
          color
          smell
          taste
      }
      class Mocha {
          color
          espresso
          McCappucinos
      }
      class Privet {
          poka
          kak_dila
      }
```

or

```mermaid
graph LR
  kak_dela(Kak delya)

  Govno-->Mocha
  Govno-->Privet

  subgraph Human
  Privet
  Mocha --> Nice
  Mocha --> kak_dela
  end 

 subgraph Kakashka
 Govno==>Smell
 Govno==>Color
 end

```

and how it looks:

Plantuml.com на базе graphviz.
Или ms word smart art как раз умеет деревья из текста с табуляцией

Есть библиотека для python для генерации блочных схем, может помочь: https://pypi.org/project/bdp/

https://markmap.js.org/repl/

1 Like

Я использую миру, очень вариативная удобная, есть даже приложения но я в браузере держу)


и оно же тут: https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio

Choose any type of chart, code and go.
Works perfectly with vscode.

Try using opensource solution: FreeMind
As alternative, you can use XMind

I guess sooner or later it will be necessary to implement those menus to FW. So why not to use some generic format (e.g. YAML is pretty readable and easy to use) and write small script that will:

  1. generate nice image representation (e.g. via Graphviz)
  2. generate *.h file with menu definition that can be used directly in FW

I hack together small PoC. It takes MD file, uses parser library from @zhovner’s example (https://github.com/gera2ld/markmap-lib) (so, NO YAML), translate it to dot syntax (Graphviz) and produces following image:

It is not interactive, on the other hand, generation of images could be part of CI pipeline.

I hack together small PoC.

Wow, amazing! Thank you.

could be part of CI pipeline

Yes, this is what I planned: on every application wiki page there can be a block with such code:

<!--- Menu structure -->

blabla
 
<!--- Menu structure end -->

And CI script will insert image right after this block.

Is it possible you write a small demo on how to make this work?