# MainDetail.ts

`

1<comment>/**</comment>

2<comment> * # MainDetail</comment>

3<comment> * </comment>

4<comment> */</comment>

5<comment>/** */</comment>

6import { Log } from <quote>'hsutil'</quote>; const log = new Log(<quote>'MainDetail'</quote>);

7import { m, Vnode} from <quote>'hslayout'</quote>;

8import { Layout } from <quote>'hslayout'</quote>;

9import { DocsNode } from <quote>'../Nodes'</quote>;

10import { DocSets } from <quote>'../DocSets'</quote>;

11

12

13<comment>/**</comment>

14<comment> * Creates Documentation on the main panel </comment>

15<comment> */</comment>

16export class MainDetail extends Layout {

17 getComponents(node:Vnode): Vnode {

18 const lib = m.route.param(<quote>'lib'</quote>);

19 const field = m.route.param(<quote>'field'</quote>);

20 node.attrs.route = undefined;

21

22 let result = DocSets.nodeCount<=0? <quote>'...'</quote> : (

23 (field===<quote>'0'</quote> || field===<quote>''</quote> || field===<quote>'overview'</quote>)?

24 getOverview(DocSets.getNode(`${lib}.overview`, lib))

25 : itemDoc(DocSets.getNode(field, lib))

26 );

27 return m(<quote>'.hsdocs'</quote>, [result || `no content for lib ${lib} and field ${field}`]);

28 }

29}

30

31<comment>/**</comment>

32<comment> * Checks if the project overview is being requested and returns the overview, </comment>

33<comment> * or `undefined` if not available</comment>

34<comment> * @param mdl the module name to check</comment>

35<comment> * @return Vnode containing the overview file, or `undefined`</comment>

36<comment> */</comment>

37function getOverview(node:DocsNode):Vnode {

38 return node? m(<quote>'div.hsdocs_head_comment'</quote>, (node.getSignatures()? node.getSignatures()[0] : node).commentLong()) : <quote>'overview unavailable'</quote>;

39}

40

41<comment>/**</comment>

42<comment> * Creates documentation for standard items in the main panel</comment>

43<comment> * @param mdl the module to document on the main panel</comment>

44<comment> */</comment>

45function itemDoc(node:DocsNode) {

46 return !node? <quote>'no item'</quote> : [

47 node.title(),

48 node.getSignatures()? undefined : m(<quote>'div.hsdocs_head_comment'</quote>, node.commentLong()),

49 node.members()

50 ];

51}

52

`