A Go utility to convert Go example tests into jupyter notebooks.

go2colab

Scientists (my main project's users) love jupyter notebook tutorials

pkg.dev.go's runnable playground doesn't support file IO but I love example tests and the fact that they update with every new release (guaranteeing docs never rot and I never need to manually update them).

So I'm writing this program that rips an entire project's example tests that include the keyword "tutorial" and packages them into jupyter notebooks that get pushed to a hosting service then update tests in godocs with associated urls.

Is this a dirty hack to get runnable IO examples? Maybe, but I'll be danged if I need to maintain tutorials on top of my libraries.

Spec

Given a Go package repo url go2colab will:

  • Store the Url
  • Extract and store the and store Repo, Owner, Branch/Commit, and Host's names from the Url
  • if the Branch/Commit isn't supplied default to commit associated latest release tag
  • Clone the git repo into a temporary directory
  • If no Branch/Commit is supplied extract the latest release tag from repo with its associated commit.
  • Parse go.mod for Go version
  • Find every example_test.go file path in the repo and its subpackages and store those in Repo.Paths
  • Iterate through example paths and extract every example test with the word "tutorial" in its definition and parse it into a Tutorial struct.
  • For each Tutorial:
    • Initalize a Notebook struct with required metadata. (an autorunning notebook cell that sets up the go kernel and env)
    • Convert Tutorial.Source to a Notebook.Cell and append it to Notebook.Cells
    • If flag - Write the notebook to a file in same directory as source example test
    • If flag - Push the notebook to hosting service with Go runtime
    • If flag - Update godocs with the tutorial's url
    • If flag - Update godocs with the tutorial's url

What this is not (unless y'all start throwing money at my github sponsors).

  • This does not convert colab notebooks to Go example tests
  • This is not a doc hosting solution
  • This is not a product
Owner
Tim
A strange creature that creates software that creates strange creatures.
Tim
Similar Resources

Robust & Easy to use struct mapper and utility methods for Go

go-model Robust & Easy to use model mapper and utility methods for Go struct. Typical methods increase productivity and make Go development more fun ?

Dec 30, 2022

gopkg is a universal utility collection for Go, it complements offerings such as Boost, Better std, Cloud tools.

gopkg is a universal utility collection for Go, it complements offerings such as Boost, Better std, Cloud tools. Table of Contents Introduction

Jan 5, 2023

Utility to add network config file in apk

Utility to add network config file in apk. Which bypass the proxy intercept restriction for user installed burpsuit CA certificate.

Aug 19, 2022

Small utility to allow simpler, quicker testing of parsing files in crowdsec

cs_parser_test Small utility to allow simpler, quicker testing of parsing files in crowdsec Usage $ sudo cs_parser_test -t syslog /var/log/mail.log N

Jul 13, 2021

sigbypass4xx is a utility to automate well-know techniques used to bypass access control restrictions.

sigbypass4xx sigbypass4xx is a utility to automate well-know techniques used to bypass access control restrictions. Resources Usage Installation From

Nov 9, 2022

Nintendo 64 ROM utility written in Go.

Nintendo 64 ROM utility written in Go.

Nintendo 64 ROM utility written in Go. Commands ls - List information about all ROMs in a directory info - Show information about a single ROM convert

Dec 7, 2022

Utility functions for work with the Kubernetes Go-Client

go-k8s-utils This repository contains utils for the work with Kubernetes, in specific with the go-client library. Testing This package contains utils

Dec 14, 2022

Scylla-octopus is a backup and maintenance utility for scylladb.

scylla-octopus: a scylladb backup utility Scylla-octopus is a backup and maintenance utility for scylladb. It attempts to reproduce some functionality

Oct 19, 2022

Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO.

cm4iofan Simple utility to get/set the PWM duty cycle and to measure the RPM for a fan connected to the 4-pin header on the CM4IO. Requirements Enable

Mar 31, 2022
Related tags
Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

Dec 29, 2022
Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

kubectl-slice: split Kubernetes YAMLs into files kubectl-slice is a neat tool that allows you to split a single multi-YAML Kubernetes manifest into mu

Jan 3, 2023
golden provides utilities for golden file tests.

golden provides utilities for golden file tests.

Dec 27, 2022
Convert Arabic numeric amounts to Chinese character

将阿拉伯数字金额转换为汉字的形式 Convert Arabic numeric amounts to Chinese character form. 安装使用 Golang 版本大于等于1.16 go get -u github.com/aliliin/rmb-character import (

Sep 9, 2021
krconv -- Convert kana-character to roman-alphabet
 krconv -- Convert kana-character to roman-alphabet

krconv -- Convert kana-character to roman-alphabet Convert kana-characters to roman-alphabets (by hepburn romanization) This package is required Go 1.

Aug 8, 2022
Package strnaming is used to Convert string to camelCase, snake_case, kebab-case.

strnaming Package strnaming is used to Convert string to camelCase, snake_case, kebab-case. Contents strnaming Contents API Examples Install Quick sta

Oct 24, 2021
Convert Gitignore to Glob patterns in Go

globify-gitignore Convert Gitignore to Glob patterns A Go

Nov 8, 2021
go-to64 analyzes Golang main package to convert int/uint to int64/uint64.

go-to64 About go-to64 analyzes Golang main package to convert int/uint to int64/uint64. This is an experiment tool, so be very careful. In a 32-bit en

Oct 31, 2021
Convert dates from or to 31 calendars in Go. Implements the functions discussed in Reingold/Dershowitz 2018.

libcalcal - Calendrical calculations in Go About libcalcal implements in Go the functions described and presented in: Reingold, Edward M., and Nachum

Dec 30, 2021
A super simple Lodash like utility library with essential functions that empowers the development in Go
A super simple Lodash like utility library with essential functions that empowers the development in Go

A simple Utility library for Go Go does not provide many essential built in functions when it comes to the data structure such as slice and map. This

Jan 4, 2023