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

Could link html docs to their documentation files on github #2648

Open
mrjbq7 opened this issue Aug 9, 2022 · 0 comments
Open

Could link html docs to their documentation files on github #2648

mrjbq7 opened this issue Aug 9, 2022 · 0 comments
Milestone

Comments

@mrjbq7
Copy link
Member

mrjbq7 commented Aug 9, 2022

From a request on Discord, we could add a link to the documentation source code on the docs.factorcode.org help files:

diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor
index aba0d61f95..0bb2768e0d 100644
--- a/basis/help/html/html.factor
+++ b/basis/help/html/html.factor
@@ -1,14 +1,14 @@
 ! Copyright (C) 2008, 2011 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays ascii assocs colors
-combinators.short-circuit debugger formatting help help.home
-help.topics help.vocabs html html.streams io.directories
-io.encodings.ascii io.encodings.binary io.encodings.utf8
-io.files io.files.temp io.pathnames kernel make math math.parser
-namespaces regexp sequences sequences.deep serialize sets
-sorting splitting strings system tools.completion vocabs
-vocabs.hierarchy words xml.data xml.syntax xml.traversal
-xml.writer ;
+combinators.short-circuit debugger definitions formatting help
+help.home help.topics help.vocabs html html.streams
+io.directories io.encodings.ascii io.encodings.binary
+io.encodings.utf8 io.files io.files.temp io.pathnames kernel
+make math math.parser namespaces regexp sequences sequences.deep
+serialize sets sorting splitting strings system tools.completion
+vocabs vocabs.hierarchy vocabs.loader words xml.data xml.syntax
+xml.traversal xml.writer ;
 FROM: io.encodings.ascii => ascii ;
 FROM: ascii => ascii? ;
 IN: help.html
@@ -62,12 +62,14 @@ M: f topic>filename* drop \ f topic>filename* ;
 
 M: topic url-of topic>filename ;
 
-M: pathname url-of
-    string>> "resource:" ?head [
+M: string url-of
+    "resource:" ?head [
         "https://github.com/factor/factor/blob/master/"
         prepend
     ] [ drop f ] if ;
 
+M: pathname url-of string>> url-of ;
+
 : help-stylesheet ( stylesheet -- xml )
     "vocab:help/html/stylesheet.css" ascii file-contents
     swap "\n" glue [XML <style><-></style> XML] ;
@@ -107,8 +109,24 @@ M: pathname url-of
         </nav>
      XML] ;
 
-: help-footer ( -- xml )
-    version-info "\n" split1 drop
+GENERIC: topic-docs-path ( topic -- docs-path )
+
+M: object topic-docs-path
+    vocab-name ".private" ?tail drop vocab-docs-path ;
+
+M: word topic-docs-path
+    dup "help-loc" word-prop
+    [ nip first ] [ vocabulary>> topic-docs-path ] if* ;
+
+: topic-link ( topic -- xml/f ) 
+    topic-docs-path [
+        [ url-of ] keep [XML
+            <a style="font-family: monospace;" href=<->><-></a>
+        XML]
+    ] [ f ] if* ;
+
+: help-footer ( topic -- xml )
+    [ version-info "\n" split1 drop ] dip topic-link
     [XML
         <footer>
         <p>
@@ -120,6 +138,7 @@ M: pathname url-of
         for more information.
         </p>
         <p><-></p>
+        <->
         </footer>
     XML] ;
 
@@ -250,9 +269,10 @@ M: pathname url-of
         [ print-topic ] with-html-writer
         css-styles-to-classes cache-images
         "resource:extra/websites/factorcode/favicon.ico" dup file-name ?copy-file
-        [ help-stylesheet help-meta prepend help-nav ] dip help-footer
-        [XML <-><div class="page"><-><-></div> XML]
-    ] bi simple-page ;
+        [ help-stylesheet help-meta prepend help-nav ] dip
+    ]
+    [ help-footer ] tri
+    [XML <-><div class="page"><-><-></div> XML] simple-page ;
 
 : generate-help-file ( topic -- )
     dup topic>filename utf8 [ help>html write-xml ] with-file-writer ;
@mrjbq7 mrjbq7 added this to the 0.100 milestone Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant