LaTeX forum ⇒ GeneralAutomating sty and doc generation

LaTeX specific issues not fitting into one of the other forums of this category.
erwann
Posts: 48
Joined: Thu Aug 25, 2016 2:24 am

Automating sty and doc generation

Postby erwann » Fri Mar 16, 2018 2:43 am

Please help modify the pieces of code in CAPITAL letters to make this work.

code.sty:
  1. % \begin{macrocode}
  2. \NeedsTeXFormat{LaTeX2e}
  3. \ProvidesPackage{foo}
  4. \usepackage{xparse}
  5. \ExplSyntaxOn
  6. % \end{macrocode}
  7. % Some internal:
  8. % \begin{macro}{NAME}
  9. % \begin{macrocode}
  10. \cs_new:Npn \ewann_impl:n #1 { (#1) }
  11. % \end{macrocode}
  12. % \end{macro}
  13. % \begin{macrocode}
  14. \ExplSyntaxOn
  15. % \end{macrocode}

Replacing NAME by \ewann_impl doesn't work (the undescore)

man.tex:
  1. \documentclass{ltxdoc}
  2. \usepackage{creatdtx}
  3. \usepackage{amsfonts}
  4.  
  5. \begin{document}
  6.  
  7. \title{foo}
  8. \author{erwann}
  9. \maketitle
  10.  
  11. % \section{Introduction}
  12. %
  13. % The intro
  14. %
  15. %\section{Install}
  16. %
  17. % Copy |THISPACKAGE.sty| to any path looked by the \LaTeX engine.
  18. %
  19. %\section{Usage}
  20. %
  21. %\DescribeMacro{\usepackage}
  22. % \cmd{\usepackage}\oarg{options}|{|\meta{path}|foo}| loads THISPACKAGE
  23. % with options OPTIONS.
  24. %
  25. % \DescribeMacro{\foo}NOINDENT\cs{foo}\marg{arg1}\marg{arg2} does something with ARG1 and ARG2
  26. %
  27. %
  28. \end{document}


Evidently, I would like THISPACKAGE to be automatically replaced by foo. The other missing bits have to do with formatting. For example, ARG1 should be like \marg{arg1} without the brackets.

From directory foo:
  1. $ makedtx.pl -author "erwann" -dir src -src "code\.sty=>foo.sty" -doc src/man.tex foo


Then, typeset foo.ins, foo.dtx.
Attachments
foo.pdf
(97.12 KiB) Downloaded 3 times
x_86 / Linux Mint 18.3 / texlive 2015.20160320-1ubuntu0.1 / TeXworks 0.5r1361 (Debian)

Tags:

erwann
Posts: 48
Joined: Thu Aug 25, 2016 2:24 am

Postby erwann » Fri Mar 16, 2018 6:33 pm

Ancillary question: I see



pop up in some of ctan's dtx. What is it, what pckg is it using?
x_86 / Linux Mint 18.3 / texlive 2015.20160320-1ubuntu0.1 / TeXworks 0.5r1361 (Debian)

erwann
Posts: 48
Joined: Thu Aug 25, 2016 2:24 am

Postby erwann » Sat Mar 17, 2018 6:30 pm

Partial answers:

If I need to describe
  1. \themacro\oarg{X}\marg{Y}

I would say "option \meta{X} is... and argument \meta{Y} is ..." (see ltxdoc.pdf).

However, if the option is of the form key=val, using \meta won't look right. I don't know how to typeset these for sure (if someone would like to clarify...), but I guess it would be like this:

  1. \NewDocumentCommand\metakeyval{mm}{ % key = <value>
  2. #1=$\langle$#2$\rangle$
  3. }
  4.  
  5. \NewDocumentCommand\metakeydefault{mm}{ % key = value (the default one)
  6. #1=#2
  7. }

Then

  1. \themacro\metakeyval{|X|}{x}\marg{Y}
  2. \themacro\metakeyvaldefault{|X|}{|x|}\marg{Y}


I have a hunch the `verbatim-ization' of the key and default value could be taken care of within the macro using xparse's argument preprocessor. Yes?

I've seen equivalents to \DescribeMacro for options in cls skdoc, lt3doc, and pkg dtxdescribe, amongst others, but they don't work in this setup (makedtx). Here's the way I do it:

  1. \usepackage{marginnote}
  2.  
  3. \marginnote{\raggedleft\meta{X}} \noindent Option that controls ...
  4.  
  5. \marginnote{\raggedleft\cs{name}} \noindent \cs{name} expands to...
x_86 / Linux Mint 18.3 / texlive 2015.20160320-1ubuntu0.1 / TeXworks 0.5r1361 (Debian)


Return to “General”

Who is online

Users browsing this forum: No registered users and 15 guests