Skip to content

Commit aa67a83

Browse files
authored
Merge pull request #340 from freihamer/introduce-navigation-pane-icd
Introduced a navigation pane on the left hand side of the generated ICD
2 parents f408f7a + c2225b8 commit aa67a83

File tree

2 files changed

+99
-23
lines changed

2 files changed

+99
-23
lines changed

BackendAst/GenerateAcnIcd.fs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,16 @@ let PrintModule stgFileName (m:Asn1Module) (f:Asn1File) (r:AstRoot) =
589589

590590
icd_acn.EmitModule stgFileName title (Path.GetFileName(f.FileName)) acnFileName commentsTail tases
591591

592+
let PrintNavLink stgFileName (m:Asn1Module) (f:Asn1File) (r:AstRoot) =
593+
let moduleName = m.Name.Value
594+
icd_acn.EmitNavLink stgFileName moduleName moduleName
592595

593596
let PrintTasses stgFileName (f:Asn1File) (r:AstRoot) =
594597
f.Modules |> Seq.map (fun m -> PrintModule stgFileName m f r ) |> String.concat "\n"
595598

599+
let PrintNavLinks stgFileName (f:Asn1File) (r:AstRoot) =
600+
f.Modules |> Seq.map (fun m -> PrintNavLink stgFileName m f r ) |> String.concat "\n"
601+
596602
let emitCss (r:AstRoot) stgFileName outFileName =
597603
let cssContent = icd_acn.RootCss stgFileName ()
598604
File.WriteAllText(outFileName, cssContent.Replace("\r", ""))
@@ -848,9 +854,10 @@ let DoWork (r:AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (stgFileNa
848854
| Some x -> x
849855
let files2 = TL "GenerateAcnIcd_PrintAsn1FileInColorizedHtml" (fun () -> r.Files |> List.map (PrintAsn1FileInColorizedHtml asn1HtmlMacros r icdHashesToPrint))
850856
let files3 = TL "GenerateAcnIcd_PrintAcnAsHTML2" (fun () -> PrintAcnAsHTML2 stgFileName r icdHashesToPrint)
857+
let navLinks = TL "GenerateAcnIcd_NavLinks" (fun () -> r.Files |> List.map (fun f -> PrintNavLinks stgFileName f r ) |> String.concat "\n")
851858
let cssFileName = Path.ChangeExtension(outFileName, ".css")
852-
let htmlContent = TL "GenerateAcnIcd_RootHtml" (fun () -> icd_acn.RootHtml stgFileName files1 files2 bAcnParamsMustBeExplained files3 (Path.GetFileName(cssFileName)))
853-
let htmlContentb = TL "GenerateAcnIcd_RootHtml_b" (fun () -> icd_acn.RootHtml stgFileName files1b files2 bAcnParamsMustBeExplained files3 (Path.GetFileName(cssFileName)))
859+
let htmlContent = TL "GenerateAcnIcd_RootHtml" (fun () -> icd_acn.RootHtml stgFileName files1 files2 bAcnParamsMustBeExplained files3 (Path.GetFileName(cssFileName)) navLinks)
860+
let htmlContentb = TL "GenerateAcnIcd_RootHtml_b" (fun () -> icd_acn.RootHtml stgFileName files1b files2 bAcnParamsMustBeExplained files3 (Path.GetFileName(cssFileName)) navLinks)
854861

855862
File.WriteAllText(outFileName, htmlContent.Replace("\r",""))
856863
File.WriteAllText(outFileName.Replace(".html", "_new.html"), htmlContentb.Replace("\r",""))

StgVarious/icdtemplate_acn.stg

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ $arrsAsn1Content$
5858

5959
EmitModule(sModName, sAsn1FileName, soAcnFileName, arrsComments, arrsTases) ::= <<
6060
<div style="width: 100%">
61+
<a name="ICD_$sModName$"></a>
6162
<h1>Module $sModName$</h1>
6263
$if(soAcnFileName)$
6364
<i>Defined in: $sAsn1FileName$, $soAcnFileName$.</i>
@@ -71,6 +72,10 @@ $arrsTases;separator="\n"$
7172
</div>
7273
>>
7374

75+
EmitNavLink(sTitle, sTarget) ::= <<
76+
<a href="#ICD_$sTarget$">$sTitle$</a>
77+
>>
78+
7479

7580
EmitTass(sTypeContent) ::= <<
7681
$sTypeContent$
@@ -135,7 +140,7 @@ $arrsItems;separator="\n"$
135140

136141
EmitSequenceOrChoice(bIsAnonymousType, sTasName, sTasNameC, bHasAcnDef, sAsn1Kinf, sMinBytes, sMaxBytes, sMaxBitsExplained, sCommentLine, arrsChildren, arrsParams, arrsComments) ::= <<
137142
<a name="ICD_$sTasNameC$"></a>
138-
<table width="100%" >
143+
<table>
139144
<tbody>
140145

141146
<tr class="typeRow">
@@ -206,7 +211,7 @@ $if(noAlignToNextSize)$
206211
$endif$
207212
<tr class="$sCssClass$">
208213
<td class="no">$nIndex$</td>
209-
<td class="field">$sName$</td>
214+
<td class="field", style="white-space: nowrap;">$sName$</td>
210215
<td class="comment">$sComment$</td>
211216
<td class="optional">$sPresentWhen$</td>
212217
<td class="type">$sType$</td>
@@ -257,7 +262,7 @@ EmitSeqChild_RefType(sRefName, sRefNameC) ::= <<
257262

258263
EmitPrimitiveType(bIsAnonymousType, sTasName, sTasNameC, bHasAcnDef, sAsnKindName, sMinBytes, sMaxBytes, sMaxBitsExplained, sCommentLine, sAsn1Constraints, sMinBits, sMaxBits, arrsParams, arrsComments, soUnit) ::= <<
259264
<a name="ICD_$sTasNameC$"></a>
260-
<table width="100%" >
265+
<table>
261266
<tbody>
262267

263268
<tr class="typeRow">
@@ -312,10 +317,9 @@ $endif$
312317
</table>
313318
>>
314319

315-
316320
EmitSizeable(bIsAnonymousType, sTasName, sTasNameC, bHasAcnDef, sKind, sMinBytes, sMaxBytes, sMaxBitsExplained, sCommentLine, arrsRows, arrsParams, arrsComments) ::= <<
317321
<a name="ICD_$sTasNameC$"></a>
318-
<table width="100%" >
322+
<table>
319323
<tbody>
320324

321325
<tr class="typeRow">
@@ -623,31 +627,96 @@ font.enumeration_name
623627
>>
624628

625629

626-
RootHtml(arrsFiles1, arrsFiles2, bAcnParamsMustBeExplained, arrsFiles3, sCssFileName) ::= <<
630+
RootHtml(arrsFiles1, arrsFiles2, bAcnParamsMustBeExplained, arrsFiles3, sCssFileName, navLinks) ::= <<
627631
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
628632
<html xmlns="http://www.w3.org/1999/xhtml" >
629633
<head>
630634
<title>ICD</title>
631635
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
632636
<link rel="stylesheet" href="$sCssFileName$" />
637+
638+
<style>
639+
* {
640+
margin: 0;
641+
padding: 0;
642+
box-sizing: border-box;
643+
}
644+
645+
body {
646+
display: flex;
647+
height: 100vh;
648+
font-family: Arial, sans-serif;
649+
}
650+
651+
/* Left Navigation Pane */
652+
.nav-pane {
653+
width: 250px;
654+
background-color: #f4f4f4;
655+
padding: 15px;
656+
overflow-y: auto;
657+
position: fixed;
658+
height: 100vh;
659+
border-right: 2px solid #ccc;
660+
}
661+
662+
.nav-pane a {
663+
display: block;
664+
padding: 5px;
665+
text-decoration: none;
666+
color: #333;
667+
border-bottom: 1px solid #ddd;
668+
font-size: 14px; /* Adjust this value as needed */
669+
}
670+
671+
.nav-pane a:hover {
672+
background-color: #ddd;
673+
}
674+
675+
/* Scrollable Content Area */
676+
.content {
677+
margin-left: 250px; /* Same width as nav */
678+
padding: 20px;
679+
overflow-y: auto;
680+
height: 100vh;
681+
flex-grow: 1;
682+
}
683+
684+
/* Example section styling */
685+
.section {
686+
padding: 20px;
687+
border-bottom: 2px solid #ddd;
688+
margin-bottom: 20px;
689+
}
690+
</style>
633691
</head>
634-
<body>
635-
<em>The following tables describe the binary encodings of the data model using the ACN Encoding Rules.
636-
</em><br/><br/>
637-
$arrsFiles1;separator="&nbsp;<br/>\n"$
638-
639-
<hr />
640-
$if(bAcnParamsMustBeExplained)$
641-
<a name="ACN_PARAMS_EXPLAINED123"></a>
642-
<em>ACN Parameters</em><br/>
643-
In the standard ASN.1 encodings such as uPER, BER etc, the encoding and decoding of any type has no external dependencies. For example, the encoded data for a SEQUENCE OF depends on the number of items in the SEQUENCE OF (the length determinant) and the type of item contained in the SEQUENCE. On the other hand, ACN allows types to be parameterized. For instance, the length of a SEQUENCE OF may be determined by the value of an external field. In this case, the SEQUENCE OF is parameterized and the input parameter is the field providing the length.
644-
<hr />
645-
<br/>
646-
$endif$
647692

648-
$arrsFiles2;separator="\n"$
693+
<body>
649694

650-
$arrsFiles3;separator="\n"$
695+
<!-- Left Navigation Pane -->
696+
<nav class="nav-pane">
697+
<h3>Navigation</h3>
698+
$navLinks;separator="&nbsp;<br/>\n"$
699+
</nav>
700+
701+
<!-- Scrollable Content Area -->
702+
<div class="content">
703+
<em>The following tables describe the binary encodings of the data model using the ACN Encoding Rules.
704+
</em><br/><br/>
705+
$arrsFiles1;separator="&nbsp;<br/>\n"$
706+
707+
<hr />
708+
$if(bAcnParamsMustBeExplained)$
709+
<a name="ACN_PARAMS_EXPLAINED123"></a>
710+
<em>ACN Parameters</em><br/>
711+
In the standard ASN.1 encodings such as uPER, BER etc, the encoding and decoding of any type has no external dependencies. For example, the encoded data for a SEQUENCE OF depends on the number of items in the SEQUENCE OF (the length determinant) and the type of item contained in the SEQUENCE. On the other hand, ACN allows types to be parameterized. For instance, the length of a SEQUENCE OF may be determined by the value of an external field. In this case, the SEQUENCE OF is parameterized and the input parameter is the field providing the length.
712+
<hr />
713+
<br/>
714+
$endif$
715+
716+
$arrsFiles2;separator="\n"$
717+
718+
$arrsFiles3;separator="\n"$
719+
</div>
651720

652721
</body>
653722
</html>

0 commit comments

Comments
 (0)