diff mbox series

[bug#56576,1/2] gnu: Add stddoc.

Message ID 20220806225743.422102-1-antero@mailbox.org
State New
Headers show
Series [bug#56576,1/2] gnu: Add stddoc. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Antero Mejr Aug. 6, 2022, 10:57 p.m. UTC
* gnu/packages/documentation.scm (stddoc): New variable.
---
Need this to generate Nuklear's HTML doc from source (code comments).

 gnu/packages/documentation.scm | 42 ++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Comments

M Aug. 7, 2022, 12:10 p.m. UTC | #1
On 07-08-2022 00:57, Antero Mejr via Guix-patches via wrote:
> +                              (invoke "gcc" "-O2" "-g" "-o" "stddoc" "stddoc.c")

For cross-compilation, you need to use #$(cc-for-target) instead of 
"gcc", otherwise it will be compiled for the wrong architecture.

> +                              (with-input-from-file "stddoc.c"
> +                                (lambda _
> +                                  (with-output-to-file "stddoc.c.html"
> +                                    (lambda _
> +                                      (invoke "./stddoc")))))))
Except when emulation is used, cross-compiled binaries cannot be run. 
However, you can add 'this-package' to native-inputs (conditional on 
cross-compilation, otherwise you get a loop) and run that stddoc:

(native-inputs (if (%current-target-system) (list this-package) '()))

[...]

(invoke #$(if (%current-target-system) "stddoc" "./stddoc"))

(untested!).

It includes Javascript and CSS from external sources:

> static void stddoc( FILE *in, FILE *out ) {
>     fprintf(out, "%s\n", "<meta charset='utf-8' emacsmode='-*- 
> markdown -*-'>");
>     fprintf(out, "%s\n", "<link rel='stylesheet' 
> href='https://casual-effects.com/m""arkdeep/latest/apidoc.css?'>");
>
I don't think this is good, privacy-wise, could you substitute them with 
a local copy?

Also, on 
<https://github.com/r-lyeh/stddoc.c/blob/6eef9deaf2e36bae812f50e448a8012b3e5efb14/stddoc.c#L111>, 
it looks like it forgets to quote things like &. I don't know if that's 
important in this particular case but often forgetting to quote things 
can be pretty bad.

(Ignoring the return value of printf also isn't ideal, but less important)

> +      (description "@code{stddoc.c} is a tiny documentation generator for 60
> +programming languages.  Markdeep code comments are extracted from stdin and
> +printed into stdout as a HTML file.")
This seems misleading to me, the Markdown->HTML happens at runtime, via 
the Javascript. Also, instead of mentioning the number 60, you could 
refer to the Javascript package; that way, the user can check if their 
language is in the list. I also don't think that the generator 
'https://morgan3d.github.io/markdeep/latest/markdeep.js' counts as tiny.

stdout -> output, stdin -> input

Greetings,
Maxime
diff mbox series

Patch

diff --git a/gnu/packages/documentation.scm b/gnu/packages/documentation.scm
index 6f24149b5d..9b98db4d40 100644
--- a/gnu/packages/documentation.scm
+++ b/gnu/packages/documentation.scm
@@ -393,3 +393,45 @@  (define-public zeal
       (description "Zeal is a simple offline documentation browser
 inspired by Dash.")
       (license gpl3+))))
+
+(define-public stddoc
+  (let ((commit "6eef9deaf2e36bae812f50e448a8012b3e5efb14"))
+    (package
+      (name "stddoc")
+      (version "1.0.2")
+      (home-page "https://github.com/r-lyeh/stddoc.c")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url home-page)
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "06phjp7wbf4x1sagxwfapgv6iyiixmijxxbg2clb48kyvjg5mlwn"))
+         (snippet #~(delete-file "stddoc.c.html"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:tests? #f ;no tests
+             #:phases #~(modify-phases %standard-phases
+                          (delete 'configure)
+                          (replace 'build
+                            (lambda _
+                              (invoke "gcc" "-O2" "-g" "-o" "stddoc" "stddoc.c")
+                              (with-input-from-file "stddoc.c"
+                                (lambda _
+                                  (with-output-to-file "stddoc.c.html"
+                                    (lambda _
+                                      (invoke "./stddoc")))))))
+                          (replace 'install
+                            (lambda _
+                              (install-file "stddoc"
+                                            (string-append #$output "/bin"))
+                              (install-file "stddoc.c.html"
+                                            (string-append #$output
+                                                           "/share/doc")))))))
+      (synopsis "Documentation generator for 60 programming languages")
+      (description "@code{stddoc.c} is a tiny documentation generator for 60
+programming languages.  Markdeep code comments are extracted from stdin and
+printed into stdout as a HTML file.")
+      (license unlicense))))