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

Add new CLI tool to allow custom html/pdf docs generation #22

Merged
merged 16 commits into from
Dec 4, 2024
Merged

Conversation

gastmaier
Copy link
Contributor

@gastmaier gastmaier commented Nov 28, 2024

Uses human friendly YAML files, e.g.:

# Custom doc builder template
# ---------------------------

# Add dirs and files to include per repo
doc:
  hdl:
    - user_guide
    - projects/ad3552r_evb
    - projects/ad4110
    - library/spi_engine

  no-OS:
    - contributing.rst
    - projects/eval-adis1657x.rst

  documentation:
    - linux/kuiper

# Per repo configuration
# extra: do steps that require extra software (e.g. vendor sdk)
# branch: clone from a specific branch, overwrites "main"
config:
    hdl:
      branch: "my-branch"
    no-OS:
      extra: true

# Include extra extensions
extensions:
    - sphinx.ext.duration

project: "Custom user guide"

Missing features:

Empty sections remover

After filtering the toctrees, some sections used to add captions to toctrees (e.g. ADCs, Obsolte IPs, etc) are left empty. those could be removed.

Missing caution:

Figure out exactly if the tool works with all Sphinx version supported. (Fixed v1)
In particular, it relies on parsing error with the suffix [some.thing] e.g. [ref.ref] and I remember not seeing it on every sphinx output. Is this configurable or something added later/before? (Fixed v1)

Not passing media_print (Fixed v1)

Check if grabbed extensions are installed on the system before calling sphinx, to gracefully fail (Fixed v1)

If a subprocess fail (eg. git clone with no internet/ssh key) gracefully return instead of keep going (Fixed v1)

Basic description on how it should be used.

Signed-off-by: Jorge Marques <[email protected]>
Allows to aggregate custom documents with filtered content using human
friendly YAML files.

Use cases:
* Tutorials
* User guides
* Driver guides

Signed-off-by: Jorge Marques <[email protected]>
Build custom doc from the template yaml.

Signed-off-by: Jorge Marques <[email protected]>
Good side-effect: will also trigger a full rebuild.

Signed-off-by: Jorge Marques <[email protected]>
@gastmaier
Copy link
Contributor Author

V0 -> V1

Custom-doc

  • Rename doc-build to custom-doc
  • Check for return code in git clone, hinting --https
  • Add show_warning_types = True to custom-doc/conf.py (is True by default only for sphinx v8.0.0)
  • Check for missing extensions
  • Patch internal references for sphinx < v8.1.0 (sphinx commit 0bfaadf6c9)
  • Pass media_print on builder pdf
  • Minor doc improvement.

Author-mode

  • Use python sphinx class.
  • Pass media_print on builder pdf

General

  • Check only if media_print env variable exist, regardless of the value (to match dev_pool var behaviour)

For LaTeX to SVG conversion.

Signed-off-by: Jorge Marques <[email protected]>
Revert media_print for hdl directives.
The reason is that improvements to the CSS fixes the original need
to have a different output for PDFs.
The media_print variable should be used in scenarios where it is
explicitly needed to compile the content in a different manner than for
the hosted html.
For example, to render some content that would instead be rendered with
JavaScript libraries in the user browser.

Signed-off-by: Jorge Marques <[email protected]>
Describe the inner workings.
Add how to use WeasyPrint and why.

Signed-off-by: Jorge Marques <[email protected]>
@gastmaier
Copy link
Contributor Author

gastmaier commented Dec 2, 2024

V1->V2

Remaining caution:

  • Table of contents depth: some depths are too shallow, hiding sub levels that could be shown. Perhaps patch this option during the custom doc code gen? Or tune directly on the docs source codes?

Missing nice to have:

  • Collapsible could have a no-print flag option to hide for pdf output (e.g. full logs)). And maybe try to add a id-anchor-permalink to replace with (similar to the video placeholder)?

Uses subprocess because creating a new Sphinx class:
* Do not re-eval the roles/directives, but
* Trigger a full rebuild due to env changes
so it is no use for developing purposes.

Maybe importlib.reload() + monkey patch could be an alternative,
but not triggering full env reload would be tricky, so this is good
enough.

Signed-off-by: Jorge Marques <[email protected]>
The Grid and Flex directives allow to dispose content in a tabular
manner.
They resolve into CSS grid and flex elements, the prior with an
explicit number of columns

Signed-off-by: Jorge Marques <[email protected]>
Add support to cd command with quotes, e.g.
$cd '/to/some path'
Most useful for ps1/windows paths.

Signed-off-by: Jorge Marques <[email protected]>
Re-enable when a better approach is figured out.

Signed-off-by: Jorge Marques <[email protected]>
Used
sass-migrator module --migrate-deps bundle.scss
following deprecation notice

Signed-off-by: Jorge Marques <[email protected]>
Signed-off-by: Jorge Marques <[email protected]>
@gastmaier gastmaier merged commit 4f32639 into main Dec 4, 2024
6 checks passed
@gastmaier gastmaier deleted the doc-build branch December 4, 2024 01:16
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

Successfully merging this pull request may close these issues.

1 participant