Skip to content
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

Several (probably all) community examples links of spork functions are broken. #195

Open
fnaj77 opened this issue Jul 8, 2023 · 9 comments

Comments

@fnaj77
Copy link

fnaj77 commented Jul 8, 2023

As per title, I've tested several links in the documentation, and all were broken (404).

Just to be clear, I mean the link to the community examples at the end of each section of spork module.

As an example, the documentation section of spork argparse (https://janet-lang.org/api/spork/index.html#spork/argparse/argparse) has a link to a janetdocs.com page with community examples (https://janetdocs.com/spork/argparse/argparse) that doesn't exist.

I don't know if those links were automatically generated and the corresponding pages never existed or if those pages have been moved.

Thanks for your time and hard work!

@sogaiu
Copy link
Contributor

sogaiu commented Jul 8, 2023

Yes, I believe:

the corresponding pages never existed

is the case.

It's been a while but IIUC janetdocs supports most of what is bundled with janet itself, but not other bits.

@fnaj77
Copy link
Author

fnaj77 commented Jul 8, 2023

Yes, I believe:

the corresponding pages never existed

is the case.

It's been a while but IIUC janetdocs supports most of what is bundled with janet itself, but not other bits.

Thank you for your reply @sogaiu .

I'm sorry, but I'm learning janet at the moment and I'm not expert enough to contribute proposing correct and idiomatic examples. Should I close this issue or leave it open to keep it more visible?

@sogaiu
Copy link
Contributor

sogaiu commented Jul 8, 2023

I don't know what might happen regarding whether the reported links should disappear or whether janetdocs might be "extended" or yet another path.

ATM, I think the links to janetdocs may be a result of this line which is part of this repository.

I would say to leave this issue open for the moment, but perhaps other folks have other ideas :)

@sogaiu
Copy link
Contributor

sogaiu commented Jun 13, 2024

The broken links have been mentioned at the zulip instance.

I don't know what's involved in removing those links. As mentioned in the previous comment, I think this line might be related.

@pepe Do you have any ideas / thoughts?

@pepe
Copy link
Member

pepe commented Jun 14, 2024

I am not sure what to do here :-(.

@sogaiu
Copy link
Contributor

sogaiu commented Jun 14, 2024

It looks like the line in question is part of the return value of emit-item and earlier in the function there is:

source-linker (dyn :source-linker janet-source-linker)

Looks like the :source-linker dynamic variable is arranged for via an .mdz file, e.g. for spork/base64, like this:

(setdyn :source-linker (partial gen-docs/github-source-linker "janet-lang/spork" gen-docs/spork-version))

May be emit-item could be modified to check for another dynamic variable that is the name of a module (e.g. spork/base64). The value could be matched on to decide not to have:

{:tag "a" "href" (string "https://janetdocs.com/" (jdoc-escape key)) :content "Community Examples"}

be part of emit-item's return value.

To get this working, all of the spork/*.mdz files would need to change too though.


Perhaps there is a simpler better idea. Not sure what yet though (^^;

@sogaiu
Copy link
Contributor

sogaiu commented Jun 15, 2024

Ok, I tried something out:

index af064c3..d80122e 100644
--- a/content/api/gen-docs.janet
+++ b/content/api/gen-docs.janet
@@ -86,7 +86,8 @@
                        (type val))
         docstring (remove-extra-spaces docstring)
         source-linker (dyn :source-linker janet-source-linker)
-        example (check-example key)]
+        example (check-example key)
+        c-example (not (dyn :no-community-examples))]
     {:tag "div" "class" "binding"
      :content [{:tag "span" "class" "binding-sym" "id" key :content key} " "
                {:tag "span" "class" "binding-type" :content binding-type} " "
@@ -98,8 +99,10 @@
                ;(if example [{:tag "div" "class" "example-title" :content "EXAMPLES"}
                              {:tag "pre" "class" "mendoza-codeblock"
                               :content {:tag "code" :language (require "janet.syntax") :content (string example)}}] [])
-
-               {:tag "a" "href" (string "https://janetdocs.com/" (jdoc-escape key)) :content "Community Examples"}]}))
+               (if c-example
+                 {:tag "a" "href"
+                  (string "https://janetdocs.com/" (jdoc-escape key))
+                  :content "Community Examples"})]}))
 
 (defn- all-entries 
   [&opt env]
diff --git a/content/api/spork/base64.mdz b/content/api/spork/base64.mdz
index a3bfb0b..8ff76a5 100644
--- a/content/api/spork/base64.mdz
+++ b/content/api/spork/base64.mdz
@@ -1,6 +1,7 @@
 (import ../gen-docs :as gen-docs)
 (import spork/base64 :export true)
 (setdyn :source-linker (partial gen-docs/github-source-linker "janet-lang/spork" gen-docs/spork-version))
+(setdyn :no-community-examples true)
 
 {:title "Base64"
  :nav-title "base64"

That seems to sort of work.

@sogaiu
Copy link
Contributor

sogaiu commented Jun 15, 2024

I guess a similar thing applies to the jpm stuff too, e.g. at the destination such as this.

@sogaiu
Copy link
Contributor

sogaiu commented Jun 15, 2024

Looks like #221 (an attempt at addressing this issue) was merged, but perhaps it's better to wait for the site to be regenerated before closing this issue (which isn't something I can do anyway :) ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants