Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing docstring on the web frontend #1000

Open
antonysigma opened this issue Apr 1, 2022 · 1 comment
Open

Printing docstring on the web frontend #1000

antonysigma opened this issue Apr 1, 2022 · 1 comment

Comments

@antonysigma
Copy link

Hi! I am wondering how I can modify the openhtf code to print the test phase docstring on the web frontend?

Docstring screenshot

For multi-line docstring, only the first line is shown. The rest of the docstrings are shown when we click the "expand all" button on the web frontend.

I know this is achievable because I have seen it work on a forked project https://gitlab.com/tackv/spintop-openhtf . In fact, I have been using spintop until the underlying company (TackV GmBH) went out of business last year.

Reference:
https://gitlab.com/tackv/spintop-openhtf/-/blob/master/docs/docs/doc/documenting.md#L6

@antonysigma
Copy link
Author

antonysigma commented Apr 1, 2022

Tracing back the commit history, it appears that the feature was mentioned at [1], which in turn results in the merge request [2]. I don't know how the control script phase_descriptor.py should be modified, but I know that the Angular web frontend code looks something like this, according to the commits at [2].

Any suggestions on how to port over the code from repo spintop_openhtf to this repo?

#  src/openhtf/output/web_gui/src/app/stations/station/phase.component.html 
<div class="htf-layout-header" [class.header-with-measurements]="showMeasurements" [class.teardown-phase]="isTeardown">
 <span class="u-clamp-text">
 <strong class="phase-name">{{ phase.name }}</strong>
- <span class="phase-doc">: {{ phase.doc }}</span>
+ <span *ngIf="!showDocExtended" class="phase-doc">: {{ phase.doc }}</span>
 <span *ngIf="phase.status !== PhaseStatus.waiting">
 &nbsp;{{ phase \| elapsedTime:'(%s)' }}
 </span>
# src/openhtf/output/web_gui/src/app/shared/models/phase.model.ts 
@@ -40,7 +40,7 @@ export class Phase {
    if (params.doc) docLines = params.doc.split("\n");
    else docLines = []
    params.doc = docLines.length > 0 ? docLines[0] : '';
-    params.docExtended = docLines.slice(1).join("\n");
+    params.docExtended = docLines.join("\n");
    Object.assign(this, params);
  }
}
# openhtf/output/web_gui/src/app/stations/station/phase.component.ts
  ngOnChanges(changes: SimpleChanges) {
    if (changes.phase) {
      this.computeDocExtended()
    }
  }

+  computeDocExtended() {
+    const doc = this.markdownService.compile(this.phase.docExtended);
+    // const safeHtml = this.sanitizer.sanitize(SecurityContext.HTML, doc);
+    this.docExtended = this.sanitizer.bypassSecurityTrustHtml(doc);
+  }

  get isTeardown() {
    return this.phase.runOptions && this.phase.runOptions.type === 'TEARDOWN'; 
  }

+  get showDocExtended() {
+    const shouldShow = this.expand || (this.expandIfRunning && this.phase.status === PhaseStatus.running);
+    return shouldShow && this.phase.docExtended;
+  }

[1] https://gitlab.com/tackv/spintop-openhtf/-/issues/10
[2] https://gitlab.com/tackv/spintop-openhtf/-/merge_requests/8

@antonysigma antonysigma changed the title Printing docstring on the webfrontend Printing docstring on the web frontend Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant