| Ticket UUID: | 534349 | |||
| Title: | add a "macro" macro to doctools... | |||
| Type: | Bug | Version: | None | |
| Submitter: | boakley | Created on: | 2002-03-24 16:42:59 | |
| Subsystem: | doctools | Assigned To: | andreas_kupries | |
| Priority: | 6 | Severity: | ||
| Status: | Closed | Last Modified: | 2002-04-02 02:06:55 | |
| Resolution: | Rejected | Closed By: | andreas_kupries | |
| Closed on: | 2002-04-01 19:06:55 | |||
| Description: |
When prototyping new macros, it's a pain to have to
hand-edit the foreach loop in mpexpand that makes safe
interpreter aliases for the macros. It would also be
nice to be able to create ad hoc macros within a man
page.
To that end, I suggest a "macro" macro, which does
nothing but create and register new macros.
For example, it might work like this (off the top of
my head):
macro myNewMacro html {arg1 arg2} {
set result "<ol><li>$arg1</li><li>$arg2</li></ol>"
}
macro myNewMacro tmml {arg1 arg2} {
set result "<bryan><shows><his><tmml><ignorace>"
append result "<foo>$arg1</foo><bar>$arg2</bar>"
}
And then to use it in a document:
blah blah
[myNewMacro "foo" "bar"]
blah blah
... and so on.
The implementation would be fairly trivial. It could
be (almost) as simple as this:
proc macro {name format arglist body} {
lappend ::textutil::expander::knownmacros $name
proc ::textutil::expander::$format::$name $arglist
$body
}
... with allowances for parameter checking, etc.
mpexpand, then, could use the "knownmacros" variable
rather than a hard-coded list of known macros.
This would make it easier to update formats without
having to update the mpexpand program. Plus, it allows
ad hoc macros in a document. We could even support
a "mpexpand.rc" file of some sort, where people could
write their own macros. For example, if I don't like
how the default rendering of [strong] works I could
write my own replacement. Or maybe I have my own
personal copyright macro that I want to use for the
documents I distribute.
| |||
| User Comments: |
andreas_kupries added on 2002-04-02 02:06:55:
Logged In: YES user_id=75003 Ok, we will not add a generic macro facility to doctools. We will add some more commands which will bring it nearer to TMML, and the rest can be handled by [proc]s in the manpage themselves. jenglish added on 2002-03-26 06:18:03: Logged In: YES user_id=68433 I agree with Andreas -- user-defined macros that expand directly to html/nroff/other output notations are not a good idea. You'd have to include a separate implementation for all the known output formats, plus all the ones that you don't know about yet. Since the latter is pretty difficult :-), I think this is a non-starter. However, [proc] *is* a legal doctools command (although this isn't documented, I believe it is intententional), so you can write your own macros that call other doctools routines. This would take care of things like a copyright macro, application-specific table types like "WIDGET OPTIONS", et cetera. boakley added on 2002-03-26 02:28:43: Logged In: YES user_id=249075 I'll admit the "I don't like how [strong] looks..." is a bad example. If we think it shouldn't be exposed to the end user, I still think it's a good idea for implementing the individual formats, if for no other reason than to make it so that mpexpand doesn't have to be modified every time someone wants to add a new standard macro. Personally, I still think it should be supported. We should discourage its use in general, but having document-specific macros could be a real time-saver for document authors. We could always make it where a document can't redefine a macro, but can only define new ones, if we're concerned with maintaining the visual appearance. One of the goals of the doctools is to make it easy to write standard formats for man pages. For me, the key word here is "easy", and I think being able to create my own macros would make it easier. Perhaps I wouldn't want it so bad if we already had a robust format definition, but we don't. Both times I've tried to use it I've run up against small obstacles in creating a standard man page. The first was the case of how the synopsis was generated, the second in creating a section detailing widget options. I'm sure there will be others until doctools becomes a bit more mature. Maybe it would help if we tried converting some of the standard tcl and tk man pages, just to see where some of the holes are in the existing set of macros. andreas_kupries added on 2002-03-26 02:05:24: Logged In: YES user_id=75003 IMHO this is not a good idea. The whole point of doctools is to have one "standard" format for manpages. This means that anyone who is writing a new output format knows what to implement. Structure of manpages and their visual appearance is completely separate. But with this facility we are going back to the state where each package and manpage defines its own extensions, actually format, and visual appearance, and a writer for a new format does not know what to expect at all. Regarding the "dislike of the default of [strong]" ... This is exactly where a new output format comes in. I for example plan to write an "ActiveState HTML" format which renders the manpages so that they fit into the general visual appearance of ActiveState's webpages. Right now I can do this because format is fully specified. If this macro facility is implemented I cannot do this anymore, or rather it is much more difficult, simply because where could be a plethora of macros out there I will know about only if I encounter them, meaning continuous work on updating my format, handling different packages using them same macro name with different meanings, etc. I strongly advise against this feature. Reassigning to Joe English for a second opinion. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki