In this demo we exercise Glamour, the Moose engine for building browsers, to build a simple code browser consisting of three columns on top for navigation showing namespaces, classes and methods, and a pane below displaying the source text of the selected method.
The browser supports basic navigation, but it is suitable for an introduction to Glamour because it covers a significant part of its mechanisms, and shows what is accomplishable in a short amount of time.
The code for building the browser is:
composer tabulator with: [:t |
t
row: [:r | r column: #namespaces; column: #classes; column: #methods];
row: #details.
t transmit to: #namespaces; andShow: [:a |
a tree
title: 'Namespaces';
display: [:mooseModel | mooseModel allNamespaces select: #isRoot];
children: #childScopes;
format: #name ].
t transmit from: #namespaces; to: #classes; andShow: [:a |
a list
title: 'Classes';
display: #classes;
format: #name ].
t transmit from: #classes; to: #methods; andShow: [:a |
a list
title: 'Methods';
display: #methods;
format: #name ].
t transmit from: #methods; to: #details; andShow: [:a |
a text
title: 'Source';
display: #formattedSourceText ].
].
composer startOn: model.You can give it a try in the latest Moose.