-
Notifications
You must be signed in to change notification settings - Fork 0
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 a directives for general purpose documentation in downstream proj… #57
base: main
Are you sure you want to change the base?
Conversation
d01c07e
to
e52e817
Compare
@stevenbal @Coperh the tests don't yet pass but mainly because I mocking out a function in CI is rather tricky due to the convoluted import sequence, trying to fix that now but it won't change the core of the PR, so I am tagging you now for feedback. |
bb37337
to
ab74c09
Compare
One thing is that I don't think it includes the templates in the release or at least when I install from github, they are missing. I do get the usage directive though |
This is a good point. I was using it locally as an editable install which did copy over the whole thing, but for |
40f9e8f
to
b6a7ec9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think generally it looks good.
I would like the ability to change the template so I can add custom intro paragraph and remove the autoclass since that is not useful for CI/CD users
_usage_template = Template((_TEMPLATES_PATH / "config_doc.rst").read_text()) | ||
_step_template = Template((_TEMPLATES_PATH / "config_step.rst").read_text()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to override these templates. Not sure if I can now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Coperh I see a few options:
- As you say, making the templates overridable. This has the drawback that Sphinx is really quite picky in building up the RST nodes (e.g. if you were to add headings or other directives, it might fail).
- Add some arguments to this directive, for instance: to include/exclude the usage info, and to add a "style" enum for the headings (which could either be the
verbose_title
, the autodac tag to the step class as now, or a combination of both - Add some additional directives which adds more composability: so the usage text, TOC, and step sections are each their own directives which could be used separately to mix-and-match, with this directive being effectively a bundle of these separate directives.
I am inclined to do that refactoring in a subsequent PR, unless there's an obvious path to 1. we can add here.
OR perhaps I could just override the _TEMPLATES_PATH? |
for step_path in configured_steps: | ||
step_cls = import_string(step_path) | ||
step_info = StepInfo( | ||
title=step_cls.verbose_name, | ||
anchor_id=slugify(step_cls.verbose_name), | ||
module_path=step_path, | ||
step_cls=step_cls, | ||
) | ||
steps_info.append(step_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you can render the step template and add it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This node thing is confusing TBH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't get this to work with just inserting the RST output directly. Because you don't know where the directive will be inserted into the final tree, it seems you have to go down this route to explicitly say you want a section with a certain title and so forth (if you do that in RST, the parser will end up complaining about "unexpected title sections" and such things).
dd90b6b
to
d49dd6c
Compare
2b8f56a
to
238f5e2
Compare
238f5e2
to
720f23e
Compare
@stevenbal @Coperh I have added a few options to customize what sections are included/excluded (See the docs and test examples). |
Example of the HTML output at https://github.com/maykinmedia/django-setup-configuration/pull/57/files#diff-3400de187b7c71517c4599f1ff9b2f4fd011921adbcdbb999e681d134e4c8438 but here's what it looks like in OIP: