Skip to content

Commit

Permalink
feat: control visibility of a single sections (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulgotor authored Jul 14, 2024
1 parent b4e29a8 commit 9108770
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to

### Added
* `auto` property to `hide-*` attributes so LinkerScope can explicitly decide whether the attribute should be hidden due to overlapping issues
* `hidden` property to sections to allow hiding one section while still computing its properties

## [0.3.1] - 2024-02-03

Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ areas:
#### Section flags

Section flags allows flagging specified sections with special properties.
These properties are `break`, `grows-up` and `grows-down`.
These properties are `hidden`, `break`, `grows-up` and `grows-down`.

Flags are listed under property `flags` and can be specified both at the map files under each section

Expand All @@ -271,6 +271,20 @@ areas:
flags: break
```

##### `hidden`

This flag marks a section or sections to be hidden. Its properties are still computed, the space
that occupies in the graph is still accounted for, but it is not shown. This could be useful, for
instance, to remove irrelevant sections while to some other more important. Another quite useful
use case is doing side by side memory maps:

![Example for side by side maps](docs/assets/side_by_side_map.svg)

> The example can be executed at the root folder by running:
> ```bash
> ./linkerscope.py examples/side_by_side_map.yaml -c examples/side_by_side_config.yaml
> ```

##### Growths
These flags specify the section as growing section, for instance, if the section is meant to grow into one direction, such as the stack.
When flagging a section with `grows-down`, an arrow pointing downwards will be appended to the bottom of the section indicating that the section is growing into that direction:
Expand Down
4 changes: 4 additions & 0 deletions map_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def _draw_area(area) -> svgwrite.container.Group:
subarea_group.add(self._make_main_frame(sub_area))

for section in sub_area.sections.get_sections():
if section.is_hidden():
continue
self._make_section(subarea_group, section, sub_area)

subarea_group.translate(sub_area.pos_x, sub_area.pos_y)
Expand Down Expand Up @@ -184,6 +186,8 @@ def draw_growths() -> svgwrite.container.Group:

area_growth = dwg.g()
for section in subarea.sections.get_sections():
if section.is_hidden():
continue
area_growth.add(self._make_growth(section))

area_growth.translate(subarea.pos_x, subarea.pos_y)
Expand Down
3 changes: 3 additions & 0 deletions section.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def is_grow_down(self):
def is_break(self):
return 'break' in self.flags

def is_hidden(self):
return 'hidden' in self.flags

def _should_element_be_hidden(self, attribute):
return True if str(attribute) in ['True', 'yes'] \
else False if str(attribute) in ['False', 'no'] \
Expand Down

0 comments on commit 9108770

Please sign in to comment.