Version-adaptive documentation: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
(add section on Lessons learned)
Line 57: Line 57:
# You can select multiple versions such as 3.9 and 3.10, but there are no smarts to know that the 3.9 content applies to 3.10, so selecting 3.10 only yields no content.
# You can select multiple versions such as 3.9 and 3.10, but there are no smarts to know that the 3.9 content applies to 3.10, so selecting 3.10 only yields no content.
# Version 4.0 can be added whenever we want.
# Version 4.0 can be added whenever we want.
# Additional work would need to be done in order to change the Table of Contents based on the version selection.
== Lessons learned about using a JavaScript in MediaWiki:Common.js ==
* The JavaScript <b>must</b> conform to ECMAScript 2009, also known as ES5.
* The script is triggered by MediaWiki, so no additional trigger is needed (such as document.body.onload).
* The content is inserted at the end of every page and is wrapped in <code><script></code> and <code></script></code> tags by MediaWiki.
* Careful consideration must be given to avoid affecting unintended MediaWiki pages.


== References ==
== References ==
* [https://github.com/duggabe/js-vad Using JavaScript to modify MediaWiki pages]
* [https://github.com/duggabe/js-vad Using JavaScript to modify MediaWiki pages]

Revision as of 13:53, 10 December 2022

Concept

I am looking into the possibility of making certain pages of our Wiki be adaptive to the user's GNU Radio version (or desired version) so that sections which don't apply would be hidden. This would make cleaner page presentations and reduce the clutter of unrelated information.

Proof of Concept

Phase 1

Plan

  • Emulate MediaWiki with a local nodeJS program to allow non-destructive testing.
  • Create a test page with sections which can be hidden, based on a 'data-vad' attribute.
  • Create a form to enter a Version selection.
  • Before displaying the page, execute a script to show or hide sections based on the Version selection.

Test results


Page before any selections are made (i.e. all information is shown).

Phase1 all.png


Version selection before clicking 'Submit'.

Gr version select.png


Version 3.9 selected. Note that the items for 3.8 are not shown (hidden).

Phase1 3-9.png


Conclusions

  1. I have found that this methodology for hiding sections of a document is relatively easy.
  2. There are several groups of pages which might benefit from this method:
    1. Block docs
    2. Tutorials
    3. Installation instructions
  3. Specific examples are:
    1. Message_Debug
    2. Packet_Communications
    3. LinuxInstall

Phase 2

Plan

  • Use a 'test' MediaWiki.
  • Put a version selection menu below the "Tools" group in the left-hand Navigation section.
  • Create a test page with HTML "div" tags which can be hidden, based on a 'data-vad' attribute.
  • Embed a JavaScript link at the end of the page HTML to perform the requested selection.

Test results


Page before any selections are made (i.e. all information is shown).

Phase2 all.png


Version 3.9 selected. Note that the items for 3.8 are not shown (hidden).

Phase2 3-9.png


Conclusions

  1. Testing with the Message_Debug_Test_Page proves the basic concept.
  2. You can select multiple versions such as 3.9 and 3.10, but there are no smarts to know that the 3.9 content applies to 3.10, so selecting 3.10 only yields no content.
  3. Version 4.0 can be added whenever we want.
  4. Additional work would need to be done in order to change the Table of Contents based on the version selection.

Lessons learned about using a JavaScript in MediaWiki:Common.js

  • The JavaScript must conform to ECMAScript 2009, also known as ES5.
  • The script is triggered by MediaWiki, so no additional trigger is needed (such as document.body.onload).
  • The content is inserted at the end of every page and is wrapped in <script> and </script> tags by MediaWiki.
  • Careful consideration must be given to avoid affecting unintended MediaWiki pages.

References