-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactoring html_doc_path
for inheritance
#63
Comments
Currently, all gems provide their own local override html_doc_path, precisely because of this issue. I don't see the difference between providing an override html_doc_path and providing File.dirname(FILE) as an initialisation parameter: you still need to remember to update something in your instantiation. So currently RSD works with:
You'd want this changed to: isodoc gem:
rsd gem:
I can do it, but I don't see why it's worth it. I do not understand what you mean by (1) at all. The SCSS processing is happening in the initialisation routine for the RSD class, and we have decided what templates we are using (the RSD templates), because we know we are in the RSD class. Where do you want to move that code to, and why? As for (2), the decision to delete the temporary CSS stylesheet in the working directory is made inside the generate_css call, after the CSS is generated. So it is subsequent to (1). (Ignore the deletion of the logo image in the foregoing; that is an artefact of the gem using a logo, but it is a separate issue.) I don't understand what the problem is, and what you want me to do about it. |
The issue is we want a single method for loading the custom CSS/templates per standard type; rather than having different methods in different gems for the same thing. In the super method, instead of “super” then setting the paths, I want to pass the path arguments to super directly. |
I still don't understand. Are you saying: IsoDoc::HtmlConvert
IsoDoc::Rsd::HtmlConvert
Asciidoctor::Rsd::Convert
True, we are now parameterising the templates in metanorma-acme. I don't see that this is that much nicer, particularly as the gem-specific template files live inside the gem: the metanorma script doesn't have access to them, and would instead have to use something like this:
Metanorma::Rsd::Processor
... I can do this, I just don't see that it's that much better. Is this what you wanted? |
Passing the template locations in as an argument has the disadvantage that we're permitting consumers to put in their own templates instead, which is a branding disaster. |
This sounds exactly like a feature that will be positively received 😉 Not everyone will have the resources to customize their own corporate gem... |
My concern is extending this facility to all gems. It is already in place in the Acme gem, which we intend as the basis for customisation. But we can always introduce override to disable it in particular gems if needed. |
I will extend this to metanorma-standoc (metanorma/metanorma-iso#62), whence it will be extended to all inheriting gems; this is now necessary for metanorma-standoc spec, because it has no embedded stylesheets. |
Put |
Resolved this by creating default_fonts and default_file_locations methods in the isodoc subclasses. The isodoc initialisation will look for font values and file locations in the options passed to it; if it does not find them, it will invoke these methods for those values instead. CSS is now being parsed within isodoc; the Implemented in asciidoctor-rsd; will be rolling out to all the other gems. |
And this is what it looks like:
|
@opoudjis can we use Ruby native methods like File/Dir to deal with file system usage rather than system? We will need to deal with Windows compatibility one day 😉 |
I'm not at all convinced Windows compatibility is going to go well for us with Ruby. But ok, let me see if I can. |
Done with all gems using |
Refactored all gems accordingly, and publishing them. |
The method
html_path_acme
was used in themetanorma-acme
gem to avoid inheritance problems of the styling paths. In theisodoc
gem, it is calledhtml_doc_path
.However, due to the way this
super
works (https://github.com/riboseinc/isodoc/blob/601c1870fea386cb54fd8b2f112f680f71bd58a3/lib/isodoc/iso/html_convert.rb#L31), thehtml_doc_path
method doesn't work with inheritance, because the method looks for the template path within the gem itself, and when inherited, it first looks for the base template in the inherited gem, and fails.In particular, in the
asciidoctor-rsd
gem, this code fails like this:This code does an additional two things -- generation of SCSS into CSS, and then adds a file to
@files_to_delete
. Both of these are problematic:Ideally, all paths (and both 1/2) should be given as options to the
initialization
method, and only after everything is resolved, the SCSS is generated, then deleted after usage.The text was updated successfully, but these errors were encountered: