X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/ca2023b8567b5e012b373eff8544be7920ce5c17..558e70ee837c7456495f5399c7e62504206ea99b:/doc/sod.sty?ds=inline

diff --git a/doc/sod.sty b/doc/sod.sty
index 457dcad..531fce0 100644
--- a/doc/sod.sty
+++ b/doc/sod.sty
@@ -215,6 +215,7 @@
 \definedescribecategory{ty}{type}
 \definedescribecategory{type}{type}
 \definedescribecategory{mac}{#1{macro}}
+\definedescribecategory{feat}{feature macro}
 \definedescribecategory{lmac}{local #1{macro}}
 \definedescribecategory{parse}{parser spec}
 \definedescribecategory{parseform}{parser form}
@@ -362,25 +363,37 @@
 }
 \def\desc@end{\endlist\after@desc\global\let\after@desc\saved@after@desc}
 
+\def\@ifnextchar@preserve#1#2#3{%
+  \let\want@= #1\def\@tempa{#2}\def\@tempb{#3}%
+  \futurelet\nch@\@ifnch@p%
+}
+\def\@ifnch@p{%
+  \ifx\want@\nch@\expandafter\@tempa\else\expandafter\@tempb\fi}
+
 \@namedef{describe*}#1{\desc@begin{#1}}
 \expandafter\let\csname enddescribe*\endcsname\desc@end
 \def\describe{\parse@dhd\desc@}
 \def\desc@#1#2#3#4#5{\desc@begin{\dhead@{#1}{#2}{#3}{#4}{#5}}}
 \let\enddescribe\desc@end
 
-\def\descref#1{\@ifnextchar[{\descref@i{#1}}{\descref@ii{#1}{}}}
-\def\descref@i#1[#2]{\descref@ii{#1}{ #2}}
-\def\descref@ii#1#2#3{%
+\def\descref{\@ifstar%
+  {\descref@i{}\@gobble{}}%
+  {\descref@i{ (}{\noexpand\autopageref}{)}}}
+\def\descref@i#1#2#3#4#5{\@ifnextchar@preserve[%
+  {\descref@ii{#1}{#2}{#3}{#4}{#5}}%
+  {\descref@iii{#1}{#2}{#3}{#4}{#5}{}}}
+\def\descref@ii#1#2#3#4#5[#6]{\descref@iii{#1}{#2}{#3}{#4}{#5}{ #6}}
+\def\descref@iii#1#2#3#4#5#6{%
   \begingroup%
     \let\protect\@empty%
     \def\@uscore{-\@gobble}%
     \edef\@tempa##1{%
       \endgroup%
-      \noexpand\hyperref[#3:#1]%
+      \noexpand\hyperref[#4:#5]%
       ##1%
-      \noexpand\autopageref{#3:#1}%
+      #2{#4:#5}%
     }%
-  \@tempa{{\code{#1}}#2 (})%
+  \@tempa{{\code{#5}}#6#1}#3%
 }
 
 %%%----- That's all, folks --------------------------------------------------
