Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active April 25, 2025 01:33
Show Gist options
  • Save sogaiu/eb90eb0209206032196da003eb0da81c to your computer and use it in GitHub Desktop.
Save sogaiu/eb90eb0209206032196da003eb0da81c to your computer and use it in GitHub Desktop.
janet doc-parse notes
  ``
  (os/compiler)

  Get the compiler used to compile the interpreter. Returns one of:

  * :gcc

  * :clang

  * :msvc

  * :unknown
  ``
  
  # candidate tree - paragraph, loose unordered list
  '@{:tag "doc"
     :content
     @[@{:tag "p" :content @["(os/compiler)"]}
       @{:tag "p"
         :content @[(string
                      "Get the compiler used to compile the interpreter. "
                      "Returns one of:")]}
      @{:tag "ul"
        :content
        @[@{:tag "li" :content @[@{:tag "p" :content @[":gcc"]}]}
          @{:tag "li" :content @[@{:tag "p" :content @[":clang"]}]}
          @{:tag "li" :content @[@{:tag "p" :content @[":msvc"]}]}
          @{:tag "li" :content @[@{:tag "p" :content @[":unknown"]}]}]}]}
  ``
  (fiber/new func &opt sigmask env)

  Create a new fiber with function body func. Can optionally take a set
  of signals `sigmask` to capture from child fibers, and an environment
  table `env`. The mask is specified as a keyword where each character
  is used to indicate a signal to block. If the ev module is enabled,
  and this fiber is used as an argument to `ev/go`, these "blocked"
  signals will result in messages being sent to the supervisor
  channel. The default sigmask is :y. For example,

      (fiber/new myfun :e123)

  blocks error signals and user signals 1, 2 and 3. The signals are as
  follows:

  * :a - block all signals
  * :d - block debug signals
  * :e - block error signals
  * :t - block termination signals: error + user[0-4]
  * :u - block user signals
  * :y - block yield signals
  * :w - block await signals (user9)
  * :r - block interrupt signals (user8)
  * :0-9 - block a specific user signal

  The sigmask argument also can take environment flags. If any mutually
  exclusive flags are present, the last flag takes precedence.

  * :i - inherit the environment from the current fiber
  * :p - the environment table's prototype is the current environment table
  ``
  
  # candidate tree - paragraph, code span, code block, tight unordered list
  '@{:tag "doc"
     :content
     @[@{:tag "p" :content @["(fiber/new func &opt sigmask env)"]}
       @{:tag "p"
         :content
         @[(string
             "Create a new fiber with function body func."
             "Can optionally take a set of signals")
           @{:tag "code" :content @["sigmask"]}
           "to capture from child fibers, and an environment table"
           @{:tag "code" :content @["env"]}
           (string
             "."
             "The mask is specified as a keyword where each character is "
             "used to indicate a signal to block. "
             "If the ev module is enabled, and this fiber is used as an "
             "argument to")
           @[:tag "code" :content @["ev/go"]]
           (string
             ", these \"blocked\" signals will result in messages being"
             "sent to the supervisor channel."
             "The default sigmask is :y."
             "For example,")]}
       # XXX: content value ends with \n or not...
       @{:tag "cb" :content @["(fiber/new myfun :e123)\n"]}
       @{:tag "p"
         :content @[(string
                      "blocks error signals and user signals 1, 2 and 3."
                      "The signals are as follows:")]}
       @{:tag "ul"
         :content
         @[@{:tag "li" :content @[":a - block all signals"]}
           @{:tag "li" :content @[":d - block debug signals"]}
           @{:tag "li" :content @[":e - block error signals"]}
           @{:tag "li"
             :content 
             @[":t - block termination signals: error + user[0-4]"]}
           @{:tag "li" :content @[":u - block user signals"]}
           @{:tag "li" :content @[":y - block yield signals"]}
           @{:tag "li" :content @[":w - block await signals (user9)"]}
           @{:tag "li" 
             :content @[":r - block interrupt signals (user8)"]}
           @{:tag "li" 
             :content @[":0-9 - block a specific user signal"]}]}
       @{:tag "p"
         :content @[(string
                      "The sigmask argument also can take environment "
                      "flags. If any mutually exclusive flags are "
                      "present, the last flag takes precedence.")]}
      @[:tag "ul"
        :content
        @[@{:tag "li"
            :content 
            @[":i - inherit the environment from the current fiber"]}
          @{:tag "li"
            :content @[(string
                         ":p - the environment table's prototype is "
                         "the current environment table")]}]]]}  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment