Skip to content

Commit

Permalink
feat(examples): add source code view doc, add r/ README (#3163)
Browse files Browse the repository at this point in the history
<!-- please provide a detailed description of the changes made in this
pull request. -->

## Description

Related to #3084

Adds a realm that teaches the user about the source code viewer in
`gnoweb`.

It also adds a `r/` root README.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
</details>

---------

Co-authored-by: Morgan <[email protected]>
  • Loading branch information
leohhhn and thehowl authored Nov 21, 2024
1 parent 7e5de12 commit 889082f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
10 changes: 10 additions & 0 deletions examples/gno.land/r/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `r/`

This directory primarily contains realms. It further branches out into namespaces:
- `demo` - realms meant to demonstrate Gno functionality
- `docs` - realms meant to teach about specific packages and concepts
- `gnoland` - official gno.land realms
- `gov` - governance realms
- `sys` - system realms
- `x` - experimental realms
- `*` - can include personal namespaces, such as `manfred`, `leon`, etc.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package add
package adder

import (
"strconv"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package add
package adder

import (
"testing"
Expand All @@ -13,7 +13,7 @@ Current Number: 0
Last Updated: Never
[Increase Number](/r/docs/add$help&func=Add&n=42)
[Increase Number](/r/docs/adder$help&func=Add&n=42)
`
if output != expected {
t.Errorf("Initial Render failed, got:\n%s", output)
Expand All @@ -36,9 +36,9 @@ Current Number: 5
Last Updated: 2009-02-13 23:31:30
[Increase Number](/r/docs/add$help&func=Add&n=42)
[Increase Number](/r/docs/adder$help&func=Add&n=42)
`
if output != expected {
t.Errorf("Final Render failed, got:\n%s", output)
t.Errorf("Final Render failed, got:\n%s\nexpected:\n%s", output, finalOutput)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module gno.land/r/docs/add
module gno.land/r/docs/adder

require gno.land/p/moul/txlink v0.0.0-latest
5 changes: 3 additions & 2 deletions examples/gno.land/r/docs/home/home.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ Explore various examples to learn more about Gno functionality and usage.
## Examples
- [Hello World](/r/docs/hello) - A simple introductory example.
- [Add](/r/docs/add) - An interactive example to update a number with transactions.
- [AVL Pager](/r/docs/avl_pager) - Paginate through AVL tree items.
- [Adder](/r/docs/adder) - An interactive example to update a number with transactions.
- [Source](/r/docs/source) - View realm source code.
- [AVL Pager](/r/docs/avl_pager) - Paginate through AVL tree items.
- ...
## Other resources
Expand Down
1 change: 1 addition & 0 deletions examples/gno.land/r/docs/source/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/docs/source
17 changes: 17 additions & 0 deletions examples/gno.land/r/docs/source/source.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package source

// Welcome to the source code of this realm!

func Render(_ string) string {
return `# Viewing source code
gno.land makes it easy to view the source code of any pure
package or realm, by using ABCI queries.
gno.land's web frontend, ` + "`gnoweb`, " + ` makes this easy by
providing a intuitive UI that fetches the source of the
realm, that you can inspect anywhere by simply clicking
on the [source] button.
Check it out in the top right corner!
`
}

0 comments on commit 889082f

Please sign in to comment.