-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Suggestion: a "demo" class and associated document #1465
Comments
Relates to #455 |
A mininum working example boilerplate class would be nice to have so we can just build on that. I tried to take an existing class, strip it down to bare basics (or so I thought) and it still won't work. |
The default book class is instructive, and a pretty short read (about 250 LoC). I recommend starting with it -- It's what I did back in sept. 2021 when I started writing my own classes, and though I eventually departed a lot from it (abstracting my headers, styles, sectioning logic etc. in separate packages, so kind of an overhaul in the end), it was a neat example to get the work started. Of course, it's not perfect and has its subtleties, but nothing blocking. Still, it could be interesting to see where others get stuck. |
A minimum working class is a bit different than a kitchen sink demo class, and not very informative either: local plain = require("classes.plain")
local myclass = pl.class(plain)
myclass._name = "myclass"
return myclass That's it. You have a working bare bones class. The next step is to start adding or overriding class functions to do what you want. The mostly likely bit you'll want to start with is an function myclass:_init (options)
-- your stuff here (if you want it before the parent init)
plain._init(self, options)
-- your stuff here (if you want it after the parent init)
return self
end From there look at existing classes to find how they do stuff like add class options or setup frames or whatever. This is spelled out in the manual by the way including code bits to setup a whole class that does ... something just for kicks. I'm not sure what else we should provide honestly. |
This is the direction I'm heading in. |
Re-reading that manual section and @alerque 's note above, it would be doable, I think, to slightly refactor it and review the progression order. Maybe I can it a try at some point? My mind is not set on this, but I could also propose to change some examples (e.g. the Bringhurst layout is not the simplest to start with, with all these "unexplained" percentages - maybe some explanations on general page layout and a Honnecourt and/or geometric division layout would allow a more thorough learning curve? Illustrating the layout could also help (... and it could be fun to extract it from the frame set rather than include an image...) Also, we have that chapter on class design, with some details on packages on the way - maybe we could refactor that a bit too, with an explicit section on packages - esp. since 0.13, there's a bit more to say than before. |
I proposed some changes in #1778 -- based in part on @alerque 's comment above, and on my own experience too. @dontlaugh @baubleb since you commented on the topic, it could be interesting to have your opinion on the matter! On the other hand, it tries at properly documenting the "bare bones" approach to packages and classes, but the general issue is (IMHO) hard to tackle with. Section numbering, running header manipulations: That's what the book class implement. That's not the only way to do it, though. If we compare, say, SILE core mechanisms and (plain)TeX, all other things being equal, it's a bit as if one wanted to have a full but short explanation of the LaTeX book class internal implementation. I am not sure it's doable, and even desirable. Folio/page number manipulation is another hard topic. Font changes, I don't know, it seems to me the manual already covers it decently? (§4.1 - but it doesn't really has anything to do with class/package design, does it?)1 Different kinds of line breaks and page breaks: What do we need beyond §4.5 (on the SIL side) and §9.2 (on the Lua side)? Widening/narrowing margins (e.g. for leading article abstract): Is the blockquote example proposed as an addition to chapter 10 in my PR addressing this concern? (Besides, §7.1 already documented something similar) Footnotes
|
I think my motivation here was actually closer to the spirit of #455 I don't know the state of that issue, but I think giving people a head start on a mildly sophisticated and hackable report/article/memo class is a great invitation to a pretty underserved market. If we consider the requirements of a report, it has a few solid elements of the "kitchen sink": Writing a report I want to
And it's likely I'm going to want to print this out, single-sided, on my office laser printer, staple it, and hand it to my colleague. In that scenario, consistent/even margins (and headers/footers!) look more appropriate than the alternating, offset style of a bound book. That's my opinion, anyway. I haven't ready your PR yet. I will check it out soon. Thank you <3 On the topic of "coding style" for classes, or teaching people how to write classes, I think there is a type of documentation that is missing from the manual: API reference documentation. The manual goes into detail about the following:
None of these are precisely the same as a comprehensive, up to date, API reference. Forgive me if this exists somewhere else and I'm just unaware. Consider this API: If I use I'm sure this isn't always straightforward with Lua, where you can set/modify objects all over the place, but certainly the standalone functions could be documented. Perhaps there's a Lua documentation framework you could adopt. |
@dontlaugh Thanks for all the details, it's really interesting, helpful and challenging! First, regarding your second point, "API reference documentation "already has some tickets about it (e.g. #493, #1337). I recognize the need here, but SILE is still in 0.x and the way forward is not that obvious. I'll be blunt, but documenting what we currently have is an effort, and I am not sure it's worth investing yet up to that point... I might be wrong, though... But it's already hard to improve and maintain the existing manual, there are a lot of things there... and many might still change for the best. Yet, some incremental improvements might be doable indeed. Actually, the "big glossary" you mentioned is also part of the problem with having a good indexer (#1339). So I would say "It's tracked', although an ETA is not obvious to state with limited resources ;-) I wanted to work on the indexer some 6 months ago, but time flees fast... Regarding your first point, hey, interesting thoughts!
As of #455, frankly... My own view on it is that i'ts a 10mn hack using my resilient stuff (hint = layout set to "none", a few styles customized, and here we are.) Again, I might be wrong, I don't write "articles", except if they eventually make it in some 300+ page "book", so my own use case is probably different ;) |
For reference, I added some additional links in my previous answer above (marked as EDIT). This being said, after having taken the time for reconsidering it, I am afraid this issue has become far too broad.
Hence, I am closing this issue. |
Creating a class can be challenging. I think the manual is pretty good at explaining the low-level mechanisms. And the built in "book" and "letter" classes are instructive.
Perhaps there is room for a "kitchen sink" kind of class, and an associated example document, that marches through some features that SILE is good at.
Some features to demonstrate in a kitchen sink class.
I'll add to this list if more comes to mind
Demonstrating these features in a "single page, single column" report style layout would be my vote. It should yield simpler Lua, if I understand correctly.
The text was updated successfully, but these errors were encountered: