shell-novice icon indicating copy to clipboard operation
shell-novice copied to clipboard

Make file tree diagrams uniform and scripted?

Open gcapes opened this issue 2 years ago • 3 comments

There are various diagrams illustrating a file tree in this lesson. Some in the main body of episode 2 which I guess were manually created, and some in the exercises which look to have been made with graphviz. Ep7 has another of the manually created diagrams. There's nothing wrong with this except when it comes to changing the lesson. It's a pain to manually recreate these drawings and is a barrier to making changes.

I've written some python using graphviz which will create diagrams from a directory tree like this. Interested in adding this to the lesson? tree-diagram.gv.pdf

gcapes avatar Nov 17 '21 10:11 gcapes

Depending on the depth to cover, I like to use tree because it discerns folders and files (folders may be disabled by -d) and yields a representation from which one may copy-paste the name of files and folders. It works best if the font is non-proportional.

For an illustration, the shell-lesson-data (fetched from here) were decompressed to the desktop. As an example to reach two levels deep (-L 2):

~/Desktop/shell-lesson-data$ tree -L 2 -d
.
├── exercise-data
│   ├── animal-counts
│   ├── creatures
│   ├── proteins
│   └── writing
└── north-pacific-gyre

6 directories

Or one providing a quick report for files and folders:

~/Desktop/shell-lesson-data$ tree exercise-data/
exercise-data/
├── animal-counts
│   └── animals.csv
├── creatures
│   ├── basilisk.dat
│   ├── minotaur.dat
│   └── unicorn.dat
├── numbers.txt
├── proteins
│   ├── cubane.pdb
│   ├── ethane.pdb
│   ├── methane.pdb
│   ├── octane.pdb
│   ├── pentane.pdb
│   └── propane.pdb
└── writing
    ├── haiku.txt
    └── LittleWomen.txt

4 directories, 13 files

nbehrnd avatar May 27 '22 15:05 nbehrnd

tree certainly makes it easy to create the representations and is already used in various places in the lesson, but maybe isn't suitable to replace all the graphical representations which are probably useful representations for many novices.

gcapes avatar Jun 06 '22 09:06 gcapes

I like the idea of generating the file structure diagrams via a script. Alternatively, I would like to suggest draw.io (https://app.diagrams.net/) In my opinion it is a very intuitive web-based tool for creating nice diagrams very fast. The project file can be stored inside the png file header. This way, the png file can be taken to reload the project in draw.io

tree-diagram draw io

braunms avatar Jul 07 '22 13:07 braunms