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

s: Bugfix in PfscDocWidgetDirective #37

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Improvements:
* Update management docs
([#34](https://github.com/proofscape/pise/pull/34)).

Bug Fixes:

* Make Sphinx doc widgets properly accept libpaths for `sel` field
([#37](https://github.com/proofscape/pise/pull/37)).


## 0.28.0 (230830)

Expand Down
12 changes: 11 additions & 1 deletion server/pfsc/sphinx/widgets/doc_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from docutils.parsers.rst.directives import unchanged

from pfsc.lang.freestrings import Libpath
from pfsc.lang.widgets import DocWidget
from pfsc.sphinx.widgets.nav_widgets import PfscNavWidgetRole
from pfsc.sphinx.widgets.base import PfscOneArgWidgetDirective
Expand All @@ -41,6 +42,15 @@ class PfscDocWidgetRole(PfscNavWidgetRole):
target_field_name = 'sel'


def libpath_or_combiner_code(s):
"""
Pass a string, which should be either a combiner code, or a libpath (potentially
relative). We decide which one it is, return it as a `Libpath` instance if we think
it's a libpath, or unchanged if we think it's a combiner code.
"""
return s if s.find(';') >= 0 else Libpath(s)


class PfscDocWidgetDirective(PfscOneArgWidgetDirective):
"""
Directive syntax for doc widgets.
Expand Down Expand Up @@ -72,5 +82,5 @@ class PfscDocWidgetDirective(PfscOneArgWidgetDirective):
option_spec = {
**PfscOneArgWidgetDirective.option_spec,
"doc": unchanged,
"sel": unchanged,
"sel": libpath_or_combiner_code,
}