PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/helplink/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / helplink
Files
3 (gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/helplink/v0
gno
0.9

Files (3)

  • gnomod.tomltoml
  • helplink.gnogno
  • helplink_test.gnogno
helplink.gnogno
1// Package helplink provides utilities for creating help page links compatible2// with Gnoweb, Gnobro, and other clients that support the Gno contracts'3// flavored Markdown format.4//5// This package simplifies the generation of dynamic, context-sensitive help6// links, enabling users to navigate relevant documentation seamlessly within7// the Gno ecosystem.8//9// For a more lightweight alternative, consider using p/moul/txlink.10//11// The primary functions — Func, FuncURL, and Home — are intended for use with12// the "relative realm". When specifying a custom Realm, you can create links13// that utilize either the current realm path or a fully qualified path to14// another realm.15package helplink1617import (18	"chain/runtime"19	"chain/runtime/unsafe"20	"strings"2122	"gno.land/p/moul/txlink/v0"23)2425var chainDomain = runtime.ChainDomain()2627// Func returns a markdown link for the specific function with optional28// key-value arguments, for the current realm.29func Func(title string, fn string, args ...string) string {30	return Realm("").Func(title, fn, args...)31}3233// FuncURL returns a URL for the specified function with optional key-value34// arguments, for the current realm.35func FuncURL(fn string, args ...string) string {36	return Realm("").FuncURL(fn, args...)37}3839// Home returns the URL for the help homepage of the current realm.40func Home() string {41	return Realm("").Home()42}4344// Realm represents a specific realm for generating help links.45type Realm string4647// prefix returns the URL prefix for the realm.48func (r Realm) prefix() string {49	// relative50	if r == "" {51		curPath := unsafe.CurrentRealm().PkgPath()52		return strings.TrimPrefix(curPath, chainDomain)53	}5455	// local realm -> /realm56	rlmstr := string(r)57	if strings.HasPrefix(rlmstr, chainDomain) {58		return strings.TrimPrefix(rlmstr, chainDomain)59	}6061	// remote realm -> https://remote.land/realm62	return "https://" + rlmstr63}6465// Func returns a markdown link for the specified function with optional66// key-value arguments.67func (r Realm) Func(title string, fn string, args ...string) string {68	// XXX: escape title69	return "[" + title + "](" + r.FuncURL(fn, args...) + ")"70}7172// FuncURL returns a URL for the specified function with optional key-value73// arguments.74func (r Realm) FuncURL(fn string, args ...string) string {75	tlr := txlink.Realm(r)76	return tlr.Call(fn, args...)77}7879// Home returns the base help URL for the specified realm.80func (r Realm) Home() string {81	return r.prefix() + "$help"82}83

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.