diff --git a/etc/pubrefman/README.adoc b/etc/pubrefman/README.adoc deleted file mode 100644 index a8929df9b..000000000 --- a/etc/pubrefman/README.adoc +++ /dev/null @@ -1,10 +0,0 @@ -= pubrefman - -This directory contains a tool to publish (update) the reference manual -on the NNG documentation site. - -Run it with --help for options. You can build it with Go. - -It normally uploads to github, and will require a working SSH agent. - -If you're not a project maintainer, you probably don't need this tool. diff --git a/etc/pubrefman/go.mod b/etc/pubrefman/go.mod deleted file mode 100644 index 7b5f56d8b..000000000 --- a/etc/pubrefman/go.mod +++ /dev/null @@ -1,44 +0,0 @@ -module go.nanomsg.org/nng/pubrefman - -go 1.18 - -require ( - github.com/bytesparadise/libasciidoc v0.8.0 - github.com/go-git/go-billy/v5 v5.5.0 - github.com/go-git/go-git/v5 v5.11.0 - github.com/google/uuid v1.3.1 - github.com/spf13/jwalterweatherman v1.1.0 -) - -require ( - dario.cat/mergo v1.0.0 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect - github.com/alecthomas/chroma/v2 v2.9.1 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dlclark/regexp2 v1.10.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/mna/pigeon v1.1.0 // indirect - github.com/onsi/ginkgo/v2 v2.12.0 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/sergi/go-diff v1.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - github.com/skeema/knownhosts v1.2.1 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/tools v0.13.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect -) diff --git a/etc/pubrefman/go.sum b/etc/pubrefman/go.sum deleted file mode 100644 index d26ec0fcb..000000000 --- a/etc/pubrefman/go.sum +++ /dev/null @@ -1,164 +0,0 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/DataDog/gostackparse v0.5.0 h1:jb72P6GFHPHz2W0onsN51cS3FkaMDcjb0QzgxxA4gDk= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink= -github.com/alecthomas/chroma/v2 v2.9.1 h1:0O3lTQh9FxazJ4BYE/MOi/vDGuHn7B+6Bu902N2UZvU= -github.com/alecthomas/chroma/v2 v2.9.1/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw= -github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytesparadise/libasciidoc v0.8.0 h1:iWAlYR7gm4Aes3NSvuGQyzRavatQpUBAJZyU9uMmwm0= -github.com/bytesparadise/libasciidoc v0.8.0/go.mod h1:Q2ZeBQ1fko5+NTUTs8rGu9gjTtbVaD6Qxg37GOPYdN4= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= -github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/felixge/fgtrace v0.1.0 h1:cuMLI5NoBg/9IxIVmJzsxA3Aoz5eIKRca6WE1U2C1zc= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= -github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= -github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= -github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 h1:gpptm606MZYGaMHMsB4Srmb6EbW/IVHnt04rcMXnkBQ= -github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/mna/pigeon v1.1.0 h1:EjlvVbkGnNGemf8OrjeJX0nH8orujY/HkJgzJtd7kxc= -github.com/mna/pigeon v1.1.0/go.mod h1:rkFeDZ0gc+YbnrXPw0q2RlI0QRuKBBPu67fgYIyGRNg= -github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= -github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190830223141-573d9926052a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/etc/pubrefman/pubrefman.go b/etc/pubrefman/pubrefman.go deleted file mode 100644 index 142a484d7..000000000 --- a/etc/pubrefman/pubrefman.go +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright 2020 Staysail Systems, Inc. -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -package main - -import ( - "context" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "path" - "sort" - "strings" - "time" - - "github.com/bytesparadise/libasciidoc" - "github.com/bytesparadise/libasciidoc/pkg/configuration" - "github.com/go-git/go-billy/v5" - "github.com/go-git/go-billy/v5/memfs" - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" - "github.com/go-git/go-git/v5/plumbing/object" - "github.com/go-git/go-git/v5/storage/memory" - "github.com/google/uuid" - jww "github.com/spf13/jwalterweatherman" -) - -type Configuration struct { - Version string - Debug bool - Trace bool - Quiet bool - DryRun bool - Author string - Email string - Url string - Message string -} - -var Config Configuration - -func init() { - flag.StringVar(&Config.Version, "v", "tip", "Version to publish") - flag.BoolVar(&Config.Debug, "d", false, "Enable debugging") - flag.BoolVar(&Config.Trace, "t", false, "Enable tracing") - flag.BoolVar(&Config.Quiet, "q", false, "Run quietly") - flag.BoolVar(&Config.DryRun, "n", false, "Dry run, does not push changes") - flag.StringVar(&Config.Url, "u", "ssh://git@github.com/nanomsg/nng.git", "URL of repo to publish from") - flag.StringVar(&Config.Email, "E", "info@staysail.tech", "Author email for commit") - flag.StringVar(&Config.Author, "A", "Staysail Systems, Inc.", "Author name for commit") - flag.StringVar(&Config.Message, "m", "", "Commit message") -} - -func (g *Global) CheckError(err error, prefix string, args ...interface{}) { - if err == nil { - g.Log.TRACE.Printf("%s: ok", fmt.Sprintf(prefix, args...)) - return - } - g.Log.FATAL.Fatalf("Error: %s: %v", fmt.Sprintf(prefix, args...), err) -} - -func (g *Global) Fatal(format string, args ...interface{}) { - g.Log.FATAL.Fatalf("Error: %s", fmt.Sprintf(format, args...)) -} - -type Section struct { - Name string - Synopsis string - Description string - Pages []*Page -} - -type Page struct { - Name string - Section string - Description string - Content string -} - -type Global struct { - Config Configuration - SrcFs billy.Filesystem - DstFs billy.Filesystem - DstDir string - LaConfig *configuration.Configuration - Sections map[string]*Section - Pages map[string]*Page - Repo *git.Repository - Index string - ToC string - Added map[string]bool - WorkTree *git.Worktree - Branch string - OldHash plumbing.Hash - NewHash plumbing.Hash - Log *jww.Notepad -} - -func (g *Global) Init() { - g.Config = Config - g.Sections = make(map[string]*Section) - g.Pages = make(map[string]*Page) - g.Added = make(map[string]bool) - g.SrcFs = memfs.New() - g.DstFs = memfs.New() - g.DstDir = path.Join("man", g.Config.Version) - g.LaConfig = configuration.NewConfiguration( - configuration.WithAttributes(map[string]interface{}{ - "nofooter": "yes", - "icons": "font", - "linkcss": "yes", - "source-highlighter": "pygments", - })) - thresh := jww.LevelInfo - if g.Config.Quiet { - thresh = jww.LevelError - } - if g.Config.Debug { - thresh = jww.LevelDebug - } - if g.Config.Trace { - thresh = jww.LevelTrace - } - g.Log = jww.NewNotepad(thresh, thresh, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime) -} - -func (g *Global) Destroy() { -} - -func (g *Global) Debug(format string, args ...interface{}) { - g.Log.DEBUG.Printf(format, args...) -} - -func (g *Global) Print(format string, args ...interface{}) { - g.Log.INFO.Printf(format, args...) -} - -func (g *Global) CloneSource() { - tag := g.Config.Version - if tag == "" || tag == "tip" { - tag = "master" - } - ref := plumbing.NewBranchReferenceName(tag) - if strings.HasPrefix(tag, "v") { - ref = plumbing.NewTagReferenceName(tag) - } - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - now := time.Now() - _, err := git.CloneContext(ctx, memory.NewStorage(), g.SrcFs, &git.CloneOptions{ - URL: g.Config.Url, - ReferenceName: ref, - }) - g.CheckError(err, "clone source") - g.Debug("Cloned source (%s) in %v", tag, time.Since(now)) -} - -func (g *Global) ClonePages() { - ref := plumbing.NewBranchReferenceName("gh-pages") - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - now := time.Now() - repo, err := git.CloneContext(ctx, memory.NewStorage(), g.DstFs, &git.CloneOptions{ - URL: g.Config.Url, - ReferenceName: ref, - RemoteName: "origin", - }) - g.CheckError(err, "clone gh-pages") - g.Repo = repo - g.Debug("Cloned pages in %v", time.Since(now)) -} - -func (g *Global) ProcessManPage(page os.FileInfo) { - source := g.ReadFile(page.Name()) - // Let's look for the description - inName := false - desc := "" - name := "" - for _, line := range strings.Split(source, "\n") { - line = strings.TrimRight(line, " \t\r") - if line == "" { - continue - } - if line == "== NAME" { - inName = true - continue - } - if inName { - w := strings.SplitN(line, " - ", 2) - if len(w) != 2 || w[1] == "" { - g.Fatal("page %s NAME malformed", page.Name()) - } - name = w[0] - desc = w[1] - strings.TrimSpace(name) - strings.TrimSpace(desc) - break - } - } - - if desc == "" { - g.Fatal("page %s NAME missing", page.Name()) - } - - html := &strings.Builder{} - - // Emit the title, as we are not letting libasciidoc do it (stripping headers) - cfg := g.LaConfig - cfg.Filename = page.Name() - cfg.LastUpdated = page.ModTime() - metadata, err := libasciidoc.Convert(strings.NewReader(source), html, cfg) - g.CheckError(err, "processing page %s", page.Name()) - w := strings.SplitN(metadata.Title, "(", 2) - sect := strings.TrimSuffix(w[1], ")") - if len(w) != 2 || name != w[0] || !strings.HasSuffix(w[1], ")") { - g.Fatal("page %s title incorrect (%s)", page.Name(), name) - } - if page.Name() != name+"."+sect+".adoc" { - g.Fatal("page %s(%s) does not match file name %s", name, sect, page.Name()) - } - result := &strings.Builder{} - _, _ = fmt.Fprintf(result, "---\n") - _, _ = fmt.Fprintf(result, "version: %s\n", g.Config.Version) - _, _ = fmt.Fprintf(result, "layout: %s\n", "manpage_v2") - _, _ = fmt.Fprintf(result, "title: %s\n", fmt.Sprintf("%s(%s)", name, sect)) - _, _ = fmt.Fprintf(result, "---\n") - _, _ = fmt.Fprintf(result, "

%s(%s)

\n", name, sect) - result.WriteString(html.String()) - - g.Pages[page.Name()] = &Page{ - Name: name, - Section: sect, - Description: desc, - Content: result.String(), - } - g.Log.TRACE.Printf("HTML for %s:\n%s\n", name, result.String()) -} - -func (g *Global) ReadFile(name string) string { - f, err := g.SrcFs.Open(path.Join("docs/man", name)) - g.CheckError(err, "open file %s", name) - b, err := ioutil.ReadAll(f) - g.CheckError(err, "read file %s", name) - return string(b) -} - -func (g *Global) LoadSection(name string) { - section := strings.TrimPrefix(name, "man") - - g.Sections[section] = &Section{ - Name: section, - Synopsis: g.ReadFile(name + ".sect"), - Description: g.ReadFile(name + ".desc"), - } -} - -func (g *Global) ProcessSource() { - pages, err := g.SrcFs.ReadDir("docs/man") - g.CheckError(err, "reading source directory") - count := 0 - g.Debug("Total of %d files in man directory", len(pages)) - now := time.Now() - for _, page := range pages { - if page.IsDir() { - continue - } - if strings.HasSuffix(page.Name(), ".sect") { - g.LoadSection(strings.TrimSuffix(page.Name(), ".sect")) - } - if !strings.HasSuffix(page.Name(), ".adoc") { - continue - } - g.ProcessManPage(page) - count++ - } - g.Debug("Processed %d pages in %v", count, time.Since(now)) -} - -func (g *Global) GenerateToC() { - toc := &strings.Builder{} - idx := &strings.Builder{} - - for _, page := range g.Pages { - if sect := g.Sections[page.Section]; sect == nil { - g.Fatal("page %s section %s not found", page.Name, page.Section) - } else { - sect.Pages = append(sect.Pages, page) - } - } - - var sects []string - for name, sect := range g.Sections { - sects = append(sects, name) - sort.Slice(sect.Pages, func(i, j int) bool { return sect.Pages[i].Name < sect.Pages[j].Name }) - } - sort.Strings(sects) - - // And also the index page. - - // Emit the toc leader part - toc.WriteString("\n") - - index := &strings.Builder{} - _, _ = fmt.Fprintf(index, "---\n") - _, _ = fmt.Fprintf(index, "version: %s\n", g.Config.Version) - _, _ = fmt.Fprintf(index, "layout: %s\n", "manpage_v2") - _, _ = fmt.Fprintf(index, "---\n") - _, _ = fmt.Fprintf(index, "

NNG Reference Manual

\n") - - cfg := g.LaConfig - cfg.Filename = "index.adoc" - _, err := libasciidoc.Convert(strings.NewReader(idx.String()), index, cfg) - g.CheckError(err, "formatting index") - g.Index = index.String() - g.ToC = toc.String() -} - -func (g *Global) CreateBranch() { - brName := uuid.New().String() - var err error - - refName := plumbing.ReferenceName("refs/heads/" + brName) - g.Branch = brName - - g.WorkTree, err = g.Repo.Worktree() - g.CheckError(err, "getting worktree") - - err = g.WorkTree.Checkout(&git.CheckoutOptions{ - Branch: refName, - Create: true, - }) - g.CheckError(err, "creating branch") - g.Print("Checked out branch %v", brName) - pr, err := g.Repo.Head() - g.CheckError(err, "getting head hash") - g.OldHash = pr.Hash() -} - -func (g *Global) WriteFile(name string, content string) { - full := path.Join(g.DstDir, name) - f, err := g.DstFs.Create(full) - g.CheckError(err, "creating file %s", name) - _, err = f.Write([]byte(content)) - g.CheckError(err, "writing file %s", name) - err = f.Close() - g.CheckError(err, "closing file %s", name) - g.Add(name) -} - -func (g *Global) Add(name string) { - g.Log.TRACE.Printf("Adding file %s", name) - g.Added[name] = true -} - -func (g *Global) Delete(name string) { - g.Debug("Removing file %s", name) - _, err := g.WorkTree.Remove(path.Join(g.DstDir, name)) - g.CheckError(err, "removing file %s", name) -} - -func (g *Global) Commit() { - if status, err := g.WorkTree.Status(); status == nil { - g.CheckError(err, "obtaining status") - } else if status.IsClean() { - g.Print("No changes to commit.") - return - } - message := g.Config.Message - if message == "" { - message = "Manual page updates for " + g.Config.Version - } - var err error - g.NewHash, err = g.WorkTree.Commit(message, &git.CommitOptions{ - Author: &object.Signature{ - Email: g.Config.Email, - Name: g.Config.Author, - When: time.Now(), - }, - }) - g.CheckError(err, "committing branch") -} - -func (g *Global) Push() { - if g.NewHash.IsZero() { - g.Print("Nothing to push.") - return - } - - ci, err := g.Repo.Log(&git.LogOptions{ - From: g.NewHash, - }) - g.CheckError(err, "getting commit log") - commit, err := ci.Next() - g.CheckError(err, "getting single commit") - if commit != nil { - g.Print(commit.String()) - if fs, _ := commit.Stats(); fs != nil { - g.Debug(fs.String()) - } - } - if g.Config.DryRun { - g.Print("Not pushing changes (dry-run mode.)") - } else { - err := g.Repo.Push(&git.PushOptions{ - RemoteName: "origin", - }) - g.CheckError(err, "pushing changes") - g.Print("Pushed branch %v\n", g.Branch) - } -} - -func (g *Global) WriteOutput() { - - for _, p := range g.Pages { - fName := fmt.Sprintf("%s.%s.html", p.Name, p.Section) - g.WriteFile(fName, p.Content) - } - g.WriteFile("_toc.html", g.ToC) - g.WriteFile("index.html", g.Index) - - _, err := g.WorkTree.Add(g.DstDir) - g.CheckError(err, "adding directory") - files, err := g.DstFs.ReadDir(g.DstDir) - g.CheckError(err, "scanning destination directory") - for _, file := range files { - if file.IsDir() { - continue - } - if g.Added[file.Name()] { - continue - } - g.Delete(file.Name()) - } - status, err := g.WorkTree.Status() - g.CheckError(err, "obtaining commit status") - if !status.IsClean() { - g.Debug("No changes.") - } else { - g.Debug(status.String()) - } -} - -func main() { - g := &Global{} - flag.Parse() - g.Init() - defer g.Destroy() - - g.CloneSource() - g.ClonePages() - g.ProcessSource() - g.GenerateToC() - g.CreateBranch() - g.WriteOutput() - g.Commit() - g.Push() -} diff --git a/etc/pubrefman/pubrefman2.go b/etc/pubrefman/pubrefman2.go deleted file mode 100644 index 145781814..000000000 --- a/etc/pubrefman/pubrefman2.go +++ /dev/null @@ -1,510 +0,0 @@ -// Copyright 2024 Staysail Systems, Inc. -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -// This tool uses a local in memory copy of git, and a docker -// installation, to format the man pages. The documentation will be -// pushed up into a branch. - -package main - -import ( - "context" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path" - "sort" - "strings" - "time" - - "github.com/go-git/go-billy/v5" - "github.com/go-git/go-billy/v5/memfs" - "github.com/go-git/go-git/v5" - "github.com/go-git/go-git/v5/plumbing" - "github.com/go-git/go-git/v5/plumbing/object" - "github.com/go-git/go-git/v5/storage/memory" - "github.com/google/uuid" - jww "github.com/spf13/jwalterweatherman" -) - -type Configuration struct { - Version string - Debug bool - Trace bool - Quiet bool - DryRun bool - Author string - Email string - Url string - Message string -} - -var Config Configuration - -func init() { - flag.StringVar(&Config.Version, "v", "tip", "Version to publish") - flag.BoolVar(&Config.Debug, "d", false, "Enable debugging") - flag.BoolVar(&Config.Trace, "t", false, "Enable tracing") - flag.BoolVar(&Config.Quiet, "q", false, "Run quietly") - flag.BoolVar(&Config.DryRun, "n", false, "Dry run, does not push changes") - flag.StringVar(&Config.Url, "u", "ssh://git@github.com/nanomsg/nng.git", "URL of repo to publish from") - flag.StringVar(&Config.Email, "E", "info@staysail.tech", "Author email for commit") - flag.StringVar(&Config.Author, "A", "Staysail Systems, Inc.", "Author name for commit") - flag.StringVar(&Config.Message, "m", "", "Commit message") -} - -func (g *Global) CheckError(err error, prefix string, args ...interface{}) { - if err == nil { - g.Log.TRACE.Printf("%s: ok", fmt.Sprintf(prefix, args...)) - return - } - g.Log.FATAL.Fatalf("Error: %s: %v", fmt.Sprintf(prefix, args...), err) -} - -func (g *Global) Fatal(format string, args ...interface{}) { - g.Log.FATAL.Fatalf("Error: %s", fmt.Sprintf(format, args...)) -} - -type Section struct { - Name string - Synopsis string - Description string - Pages []*Page -} - -type Page struct { - Name string - Section string - Description string - Content string -} - -type Global struct { - Config Configuration - SrcFs billy.Filesystem - DstFs billy.Filesystem - DstDir string - Sections map[string]*Section - Pages map[string]*Page - Repo *git.Repository - Index string - ToC string - Added map[string]bool - WorkTree *git.Worktree - Branch string - OldHash plumbing.Hash - NewHash plumbing.Hash - Log *jww.Notepad -} - -func (g *Global) Init() { - g.Config = Config - g.Sections = make(map[string]*Section) - g.Pages = make(map[string]*Page) - g.Added = make(map[string]bool) - g.SrcFs = memfs.New() - g.DstFs = memfs.New() - g.DstDir = path.Join("man", g.Config.Version) - thresh := jww.LevelInfo - if g.Config.Quiet { - thresh = jww.LevelError - } - if g.Config.Debug { - thresh = jww.LevelDebug - } - if g.Config.Trace { - thresh = jww.LevelTrace - } - g.Log = jww.NewNotepad(thresh, thresh, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime) -} - -func (g *Global) Destroy() { -} - -func (g *Global) Debug(format string, args ...interface{}) { - g.Log.DEBUG.Printf(format, args...) -} - -func (g *Global) Print(format string, args ...interface{}) { - g.Log.INFO.Printf(format, args...) -} - -func (g *Global) CloneSource() { - tag := g.Config.Version - if tag == "" || tag == "tip" { - tag = "master" - } - ref := plumbing.NewBranchReferenceName(tag) - if strings.HasPrefix(tag, "v") { - ref = plumbing.NewTagReferenceName(tag) - } - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - now := time.Now() - _, err := git.CloneContext(ctx, memory.NewStorage(), g.SrcFs, &git.CloneOptions{ - URL: g.Config.Url, - ReferenceName: ref, - }) - g.CheckError(err, "clone source") - g.Debug("Cloned source (%s) in %v", tag, time.Since(now)) -} - -func (g *Global) ClonePages() { - ref := plumbing.NewBranchReferenceName("gh-pages") - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - now := time.Now() - repo, err := git.CloneContext(ctx, memory.NewStorage(), g.DstFs, &git.CloneOptions{ - URL: g.Config.Url, - ReferenceName: ref, - RemoteName: "origin", - }) - g.CheckError(err, "clone gh-pages") - g.Repo = repo - g.Debug("Cloned pages in %v", time.Since(now)) -} - -func (g *Global) DockerCmd(source string, output *strings.Builder) *exec.Cmd { - cmd := exec.Command("/usr/local/bin/docker", "run", "-i", "--rm", "asciidoctor/docker-asciidoctor") - cmd.Args = append(cmd.Args, "asciidoctor") - cmd.Args = append(cmd.Args, "-a", "linkcss") - cmd.Args = append(cmd.Args, "-a", "icons=font") - cmd.Args = append(cmd.Args, "-a", "nofooter") - cmd.Args = append(cmd.Args, "-a", "source-highlighter=pygments") // rouge is recommended, but our stylesheet is for pygments - cmd.Args = append(cmd.Args, "-s", "-o", "-", "-") // pipe it - cmd.Stdin = strings.NewReader(source) - cmd.Stdout = output - cmd.Stderr = &strings.Builder{} - - return cmd -} - -func (g *Global) ProcessManPage(page os.FileInfo) { - source := g.ReadFile(page.Name()) - // Let's look for the description - inName := false - desc := "" - name := "" - title := "" - for _, line := range strings.Split(source, "\n") { - line = strings.TrimRight(line, " \t\r") - if line == "" { - continue - } - if strings.HasPrefix(line, "= ") { - title = strings.TrimSpace(line[2:]) - continue - } - if line == "== NAME" { - inName = true - continue - } - if inName { - w := strings.SplitN(line, " - ", 2) - if len(w) != 2 || w[1] == "" { - g.Fatal("page %s NAME malformed", page.Name()) - } - name = w[0] - desc = w[1] - strings.TrimSpace(name) - strings.TrimSpace(desc) - break - } - } - - if desc == "" { - g.Fatal("page %s NAME missing", page.Name()) - } - if title == "" { - g.Fatal("page %s title missing", page.Name()) - } - - html := &strings.Builder{} - w := strings.SplitN(title, "(", 2) - sect := strings.TrimSuffix(w[1], ")") - if len(w) != 2 || name != w[0] || !strings.HasSuffix(w[1], ")") { - g.Fatal("page %s title incorrect (%s)", page.Name(), name) - } - if page.Name() != name+"."+sect+".adoc" { - g.Fatal("page %s(%s) does not match file name %s", name, sect, page.Name()) - } - _, _ = fmt.Fprintf(html, "---\n") - _, _ = fmt.Fprintf(html, "version: %s\n", g.Config.Version) - _, _ = fmt.Fprintf(html, "layout: %s\n", "manpage_v2") - _, _ = fmt.Fprintf(html, "title: %s\n", fmt.Sprintf("%s(%s)", name, sect)) - _, _ = fmt.Fprintf(html, "---\n") - _, _ = fmt.Fprintf(html, "

%s(%s)

\n", name, sect) - - - cmd := g.DockerCmd(source, html) - err := cmd.Run() - if err != nil { - g.Fatal("Failed %v: %s", err, cmd.Stderr) - } - - g.Pages[page.Name()] = &Page{ - Name: name, - Section: sect, - Description: desc, - Content: html.String(), - } - g.Log.TRACE.Printf("HTML for %s:\n%s\n", name, html.String()) -} - -func (g *Global) ReadFile(name string) string { - f, err := g.SrcFs.Open(path.Join("docs/man", name)) - g.CheckError(err, "open file %s", name) - b, err := ioutil.ReadAll(f) - g.CheckError(err, "read file %s", name) - return string(b) -} - -func (g *Global) LoadSection(name string) { - section := strings.TrimPrefix(name, "man") - - g.Sections[section] = &Section{ - Name: section, - Synopsis: g.ReadFile(name + ".sect"), - Description: g.ReadFile(name + ".desc"), - } -} - -func (g *Global) ProcessSource() { - pages, err := g.SrcFs.ReadDir("docs/man") - g.CheckError(err, "reading source directory") - count := 0 - g.Debug("Total of %d files in man directory", len(pages)) - now := time.Now() - for i, page := range pages { - if page.IsDir() { - continue - } - if strings.HasSuffix(page.Name(), ".sect") { - g.LoadSection(strings.TrimSuffix(page.Name(), ".sect")) - } - if !strings.HasSuffix(page.Name(), ".adoc") { - continue - } - g.ProcessManPage(page) - g.Print("Processed %s (%d of %d)", page.Name(), i, len(pages)) - count++ - } - g.Print("Processed %d pages in %v", count, time.Since(now)) -} - -func (g *Global) GenerateToC() { - toc := &strings.Builder{} - idx := &strings.Builder{} - - for _, page := range g.Pages { - if sect := g.Sections[page.Section]; sect == nil { - g.Fatal("page %s section %s not found", page.Name, page.Section) - } else { - sect.Pages = append(sect.Pages, page) - } - } - - var sects []string - for name, sect := range g.Sections { - sects = append(sects, name) - sort.Slice(sect.Pages, func(i, j int) bool { return sect.Pages[i].Name < sect.Pages[j].Name }) - } - sort.Strings(sects) - - // And also the index page. - - // Emit the toc leader part - toc.WriteString("\n") - - index := &strings.Builder{} - _, _ = fmt.Fprintf(index, "---\n") - _, _ = fmt.Fprintf(index, "version: %s\n", g.Config.Version) - _, _ = fmt.Fprintf(index, "layout: %s\n", "manpage_v2") - _, _ = fmt.Fprintf(index, "---\n") - _, _ = fmt.Fprintf(index, "

NNG Reference Manual

\n") - - cmd := g.DockerCmd(idx.String(), index) - cmd.Stdout = index - err := cmd.Run() - g.CheckError(err, "formatting index") - g.Index = index.String() - g.ToC = toc.String() -} - -func (g *Global) CreateBranch() { - brName := uuid.New().String() - var err error - - refName := plumbing.ReferenceName("refs/heads/" + brName) - g.Branch = brName - - g.WorkTree, err = g.Repo.Worktree() - g.CheckError(err, "getting worktree") - - err = g.WorkTree.Checkout(&git.CheckoutOptions{ - Branch: refName, - Create: true, - }) - g.CheckError(err, "creating branch") - g.Print("Checked out branch %v", brName) - pr, err := g.Repo.Head() - g.CheckError(err, "getting head hash") - g.OldHash = pr.Hash() -} - -func (g *Global) WriteFile(name string, content string) { - full := path.Join(g.DstDir, name) - f, err := g.DstFs.Create(full) - g.CheckError(err, "creating file %s", name) - _, err = f.Write([]byte(content)) - g.CheckError(err, "writing file %s", name) - err = f.Close() - g.CheckError(err, "closing file %s", name) - g.Add(name) -} - -func (g *Global) Add(name string) { - g.Log.TRACE.Printf("Adding file %s", name) - g.Added[name] = true -} - -func (g *Global) Delete(name string) { - g.Debug("Removing file %s", name) - _, err := g.WorkTree.Remove(path.Join(g.DstDir, name)) - g.CheckError(err, "removing file %s", name) -} - -func (g *Global) Commit() { - if status, err := g.WorkTree.Status(); status == nil { - g.CheckError(err, "obtaining status") - } else if status.IsClean() { - g.Print("No changes to commit.") - return - } - message := g.Config.Message - if message == "" { - message = "Manual page updates for " + g.Config.Version - } - var err error - g.NewHash, err = g.WorkTree.Commit(message, &git.CommitOptions{ - Author: &object.Signature{ - Email: g.Config.Email, - Name: g.Config.Author, - When: time.Now(), - }, - }) - g.CheckError(err, "committing branch") -} - -func (g *Global) Push() { - if g.NewHash.IsZero() { - g.Print("Nothing to push.") - return - } - - ci, err := g.Repo.Log(&git.LogOptions{ - From: g.NewHash, - }) - g.CheckError(err, "getting commit log") - commit, err := ci.Next() - g.CheckError(err, "getting single commit") - if commit != nil { - g.Print(commit.String()) - if fs, _ := commit.Stats(); fs != nil { - g.Debug(fs.String()) - } - } - if g.Config.DryRun { - g.Print("Not pushing changes (dry-run mode.)") - } else { - err := g.Repo.Push(&git.PushOptions{ - RemoteName: "origin", - }) - g.CheckError(err, "pushing changes") - g.Print("Pushed branch %v\n", g.Branch) - } -} - -func (g *Global) WriteOutput() { - - for _, p := range g.Pages { - fName := fmt.Sprintf("%s.%s.html", p.Name, p.Section) - g.WriteFile(fName, p.Content) - } - g.WriteFile("_toc.html", g.ToC) - g.WriteFile("index.html", g.Index) - - _, err := g.WorkTree.Add(g.DstDir) - g.CheckError(err, "adding directory") - files, err := g.DstFs.ReadDir(g.DstDir) - g.CheckError(err, "scanning destination directory") - for _, file := range files { - if file.IsDir() { - continue - } - if g.Added[file.Name()] { - continue - } - g.Delete(file.Name()) - } - status, err := g.WorkTree.Status() - g.CheckError(err, "obtaining commit status") - if !status.IsClean() { - g.Debug("No changes.") - } else { - g.Debug(status.String()) - } -} - -func main() { - g := &Global{} - flag.Parse() - g.Init() - defer g.Destroy() - - g.CloneSource() - g.ClonePages() - g.ProcessSource() - g.GenerateToC() - g.CreateBranch() - g.WriteOutput() - g.Commit() - g.Push() -}