Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • oss/utilities/documentation-manager
1 result
Select Git revision
Show changes
Showing
with 76 additions and 786 deletions
version: '3'
tasks:
default:
aliases:
- help
cmds:
- task --list
build:
desc: Build the app
aliases:
- b
vars:
DEVENV_ROOT:
sh: echo "$DEVENV_ROOT"
cmds:
- devenv shell build-app
sources:
- source/**/*.go
- source/**/*.mod
- dist/**
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
type Definition struct {
ConfigurationPath string `long:"config" short:"c"`
Version VersionDefinition `command:"version" alias:"v"`
Document DocumentDefinition `command:"document" alias:"d"`
Server ServerDefinition `command:"server" alias:"s"`
}
func (d *Definition) GetConfigurationPath() string {
return d.ConfigurationPath
}
var definition *Definition
func init() {
definition = &Definition{}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"strings"
)
func initCommands() {
for n, h := range environment.Handlers.Executor {
x := strings.Split(n, "-")
var c *flags.Command
for i, y := range x {
if i == 0 {
c = environment.State.FindCommand(y)
} else {
if c == nil {
environment.ExitWithError(1, "Command %s not found", y)
}
c = c.Find(y)
}
}
if c != nil {
h.Init(c)
}
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"errors"
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const (
// Generic codes.
CodeOK = 0 // success
CodeErr = 1 // generic error
CodeHelpErr = 2 // command is invoked with -help or -h flag but no such flag is defined
// Codes as defined in /usr/include/sysexits.h on *nix systems.
CodeUsage = 64 // command line usage error
CodeDataErr = 65 // data format error
CodeNoInput = 66 // cannot open input
CodeNoUser = 67 // addressee unknown
CodeNoHost = 68 // host name unknown
CodeUnavailable = 69 // service unavailable
CodeSoftware = 70 // internal software error
CodeOSErr = 71 // system error (e.g., can't fork)
CodeOSFile = 72 // critical OS file missing
CodeCantCreat = 73 // can't create (user) output file
CodeIOErr = 74 // input/output error
CodeTempFail = 75 // temp failure; user is invited to retry
CodeProtocol = 76 // remote error in protocol
CodeNoPerm = 77 // permission denied
CodeConfig = 78 // configuration error
)
var (
notPermittedError = errors.New(translations.T.Sprintf("Not permitted"))
)
func checkFlagsError(err error) {
e := err.(*flags.Error)
switch e.Type {
case flags.ErrUnknown:
environment.State.AddError(translations.T.Sprintf("flag error unknown")).Exit()
case flags.ErrExpectedArgument:
environment.State.AddError(translations.T.Sprintf("expected argument")).Exit()
case flags.ErrUnknownFlag:
environment.State.AddError(translations.T.Sprintf("unknown flag")).Exit()
case flags.ErrUnknownGroup:
environment.State.AddError(translations.T.Sprintf("unknown group")).Exit()
case flags.ErrMarshal:
environment.State.AddError(translations.T.Sprintf("marshal")).Exit()
case flags.ErrHelp:
environment.State.Exit()
case flags.ErrNoArgumentForBool:
environment.State.AddError(translations.T.Sprintf("no argument for bool")).Exit()
case flags.ErrRequired:
environment.State.Exit()
case flags.ErrShortNameTooLong:
environment.State.AddError(translations.T.Sprintf("short name too long")).Exit()
case flags.ErrDuplicatedFlag:
environment.State.AddError(translations.T.Sprintf("duplicated flag")).Exit()
case flags.ErrTag:
environment.State.AddError(translations.T.Sprintf("tag %s", err.Error())).Exit()
case flags.ErrCommandRequired:
environment.State.Exit()
case flags.ErrUnknownCommand:
environment.State.AddError(translations.T.Sprintf("unknown command")).Exit()
case flags.ErrInvalidChoice:
environment.State.AddError(translations.T.Sprintf("invalid choice")).Exit()
case flags.ErrInvalidTag:
environment.State.AddError(translations.T.Sprintf("invalid tag")).Exit()
default:
environment.State.AddError(translations.T.Sprintf("unrecognized error type")).Exit()
}
}
func checkError(err error) {
if err == nil {
return
}
switch err.(type) {
case *flags.Error:
checkFlagsError(err)
}
environment.ExitWithError(1, "Unknown Error: %s", err.Error())
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
"strings"
)
func Execute(Info environment.InfoStruct) {
environment.State.SetInfo(Info)
initTerminalState()
initCommands()
_, err := environment.State.ParseArguments()
checkError(err)
environment.InitConfiguration(definition.ConfigurationPath)
a := environment.State.GetParser().Command.Active
if a == nil {
environment.ExitWithError(1, "No active command found")
}
queue := []string{}
runCommand(queue, environment.State.GetParser().Command.Active)
}
func initTerminalState() {
parser := flags.NewParser(definition, flags.Default)
parser.ShortDescription = translations.T.Sprintf("This program can be used to create documentation for your project.")
parser.LongDescription = translations.T.Sprintf("This program can be used to create documentation for your project.\nIt can be used to create a new documentation project,\nadd new documentation to an existing project, or to generate\ndocumentation from a source code project.")
environment.State.SetParser(parser)
//State.definition = definition
}
func runCommand(queue []string, activeCommand *flags.Command) {
queue = append(queue, activeCommand.Name)
if activeCommand.Active != nil {
runCommand(queue, activeCommand.Active)
return
}
k := strings.Join(queue, "-")
if handler, ok := environment.Handlers.Executor[k]; ok {
execute := handler.Execute
execute(activeCommand)
} else {
environment.ExitWithError(1, "handler %s not found", k)
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const documentSymbol = "document"
func init() {
h := environment.Handler{
Init: initDocument,
}
environment.Handlers.Executor[documentSymbol] = h
}
type DocumentDefinition struct {
SourcePath string `long:"path" short:"p"`
DateFormat string `long:"date-format" short:"d"`
Add DocumentAddDefinition `command:"add" alias:"a"`
HTML DocumentHTMLDefinition `command:"html" alias:"h"`
PDF DocumentPDFDefinition `command:"pdf"`
}
func initDocument(command *flags.Command) {
const text = "Functions for creating and editing documents"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
for _, opt := range command.Options() {
switch opt.LongName {
case "path":
opt.Description = translations.T.Sprintf("base directory in which the documents are saved")
case "date-format":
opt.Description = translations.T.Sprintf("date format for the creation date")
}
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/document"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
"time"
)
const documentAddSymbol = "document-add"
// language: md
const newDocumentTemplate = `
---
# Document title
Title: New Document
# keywords mainly used for searching
Keywords:
- documentation
References:
- https://www.example.com/
# Abbreviation of the document
Abbreviation:
# First and last name of the authors as a list
Authors:
- null
Version: 1.0
Created: %%CREATED%%
Last Update: %%CREATED%%
Language: en
# Which level of the document is this?
Level: 1
...
## {{ .Title }}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
`
func init() {
h := environment.Handler{
Init: initDocumentAdd,
Execute: runDocumentAdd,
}
environment.Handlers.Executor[documentAddSymbol] = h
}
type DocumentAddDefinition struct {
Template string `long:"template" short:"t"`
Positional struct {
Name []string `positional-arg-name:"name" required:"yes" positional:"yes"`
} `positional-args:"yes" required:"yes"`
}
func initDocumentAdd(command *flags.Command) {
const text = "Adds a new document"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
for _, opt := range command.Options() {
switch opt.LongName {
case "template":
opt.Description = translations.T.Sprintf("template for the new document")
}
}
for _, arg := range command.Args() {
switch arg.Name {
case "name":
arg.Description = translations.T.Sprintf("file names of the new documents, separated by spaces")
}
}
}
func runDocumentAdd(command *flags.Command) {
names := definition.Document.Add.Positional.Name
if len(names) == 0 {
environment.ExitWithError(1, "no document name given")
}
root := environment.State.GetDocumentPath(definition.Document.SourcePath)
template := environment.State.GetDocumentTemplate(definition.Document.Add.Template)
date := time.Now().Format(environment.State.GetDocumentDateFormat(definition.Document.DateFormat))
if template == "" {
template = newDocumentTemplate
}
for _, name := range names {
document.CreateNewDocument(name, root, template, date)
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/document"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const documentHTMLSymbol = "document-html"
func init() {
h := environment.Handler{
Init: initDocumentHTML,
Execute: runDocumentHTML,
}
environment.Handlers.Executor[documentHTMLSymbol] = h
}
type DocumentHTMLDefinition struct {
SinglePage bool `long:"single-page" short:"s"`
HTMLTemplate string `long:"html-template" short:"h"`
MarkdownTemplate string `long:"markdown-template" short:"m"`
OutputPath string `long:"output" short:"o"`
Verbose bool `long:"verbose" short:"v"`
}
func initDocumentHTML(command *flags.Command) {
const text = "Build the documentation as PDF"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
for _, opt := range command.Options() {
switch opt.LongName {
case "html-template":
opt.Description = translations.T.Sprintf("html template for the new document")
case "markdown-template":
opt.Description = translations.T.Sprintf("markdown template for the new document")
case "output":
opt.Description = translations.T.Sprintf("filename for the new document")
case "verbose":
opt.Description = translations.T.Sprintf("verbose output")
case "single-page":
opt.Description = translations.T.Sprintf("single page output")
}
}
}
func runDocumentHTML(command *flags.Command) {
env := document.BuildHtmlEnvironment{
DateFormat: environment.State.GetDocumentDateFormat(definition.Document.DateFormat),
SourcePath: environment.State.GetDocumentPath(definition.Document.SourcePath),
OutputPath: environment.State.GetDocumentHTMLOutputPath(definition.Document.PDF.OutputPath),
}
env.Templates.HTML = environment.State.GetHTMLHTMLTemplatePath(definition.Document.HTML.HTMLTemplate)
env.Verbose = definition.Document.HTML.Verbose
env.SinglePage = environment.State.GetHTMLSinglePageState(definition.Document.HTML.SinglePage)
document.BuildHTML(env)
if environment.State.HasErrorsWarningsOrMessages() {
environment.PrintMessages()
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/document"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const documentPdfSymbol = "document-pdf"
func init() {
h := environment.Handler{
Init: initDocumentPDF,
Execute: runDocumentPDF,
}
environment.Handlers.Executor[documentPdfSymbol] = h
}
type DocumentPDFDefinition struct {
LatexTemplate string `long:"latex-template" short:"l"`
MarkdownTemplate string `long:"markdown-template" short:"m"`
OutputPath string `long:"output" short:"o"`
Verbose bool `long:"verbose" short:"v"`
}
func initDocumentPDF(command *flags.Command) {
const text = "Build the documentation as PDF"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
for _, opt := range command.Options() {
switch opt.LongName {
case "latex-template":
opt.Description = translations.T.Sprintf("latex template for the new document")
case "markdown-template":
opt.Description = translations.T.Sprintf("md template for the new document")
case "output":
opt.Description = translations.T.Sprintf("filename for the new document")
case "verbose":
opt.Description = translations.T.Sprintf("verbose output")
}
}
}
func runDocumentPDF(command *flags.Command) {
env := document.BuildPdfEnvironment{
DateFormat: environment.State.GetDocumentDateFormat(definition.Document.DateFormat),
SourcePath: environment.State.GetDocumentPath(definition.Document.SourcePath),
OutputPath: environment.State.GetDocumentPDFOutputPath(definition.Document.PDF.OutputPath),
}
env.Templates.Latex = environment.State.GetPDFLatexTemplatePath(definition.Document.PDF.LatexTemplate)
env.Templates.Markdown = environment.State.GetPDFMarkdownTemplatePath(definition.Document.PDF.MarkdownTemplate)
env.Verbose = definition.Document.PDF.Verbose
document.BuildPDF(env)
if environment.State.HasErrorsWarningsOrMessages() {
environment.PrintMessages()
}
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const versionSymbol = "version"
func init() {
h := environment.Handler{
Init: initVersion,
Execute: runVersion,
}
environment.Handlers.Executor[versionSymbol] = h
}
type VersionDefinition struct {
}
func initVersion(command *flags.Command) {
const text = "Prints the version and build information"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
}
func runVersion(command *flags.Command) {
translations.T.Printf("version: %s\n", environment.State.GetVersion())
translations.T.Printf("build: %s\n", environment.State.GetBuild())
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const serverSymbol = "server"
func init() {
h := environment.Handler{
Init: initServer,
}
environment.Handlers.Executor[serverSymbol] = h
}
type ServerDefinition struct {
Serve ServerServeDefinition `command:"serve" alias:"s"`
}
func initServer(command *flags.Command) {
const text = "Server command"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package commands
import (
"fmt"
"github.com/jessevdk/go-flags"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
"gitlab.schukai.com/oss/utilities/documentation-manager/translations"
)
const serverServeSymbol = "server-serve"
func init() {
h := environment.Handler{
Init: initServerServe,
Execute: runServerServe,
}
environment.Handlers.Executor[serverServeSymbol] = h
}
type ServerServeDefinition struct {
}
func initServerServe(command *flags.Command) {
const text = "Server command"
command.ShortDescription = translations.T.Sprintf(text)
command.LongDescription = translations.T.Sprintf(text)
}
func runServerServe(command *flags.Command) {
fmt.Println("Server command")
}
module gitlab.schukai.com/oss/utilities/documentation-manager
go 1.19
require (
github.com/PuerkitoBio/goquery v1.8.0
github.com/andybalholm/cascadia v1.3.1
github.com/evanw/esbuild v0.14.49
github.com/gomarkdown/markdown v0.0.0-20221013030248-663e2500819c
github.com/gookit/color v1.5.2
github.com/gosimple/slug v1.13.1
github.com/jessevdk/go-flags v1.5.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/mattn/go-shellwords v1.0.12
github.com/sethvargo/go-envconfig v0.8.3
github.com/tdewolff/minify/v2 v2.12.4
github.com/yuin/goldmark v1.5.3
golang.org/x/net v0.5.0
golang.org/x/text v0.6.0
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/13rac1/goldmark-embed v0.0.0-20201220231550-e6806f2de66a // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/go-chi/chi/v5 v5.0.7 // indirect
github.com/go-chi/docgen v1.2.0 // indirect
github.com/go-chi/httprate v0.5.3 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/tdewolff/parse/v2 v2.6.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/sys v0.4.0 // indirect
)
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package main
import (
"gitlab.schukai.com/oss/utilities/documentation-manager/commands"
"gitlab.schukai.com/oss/utilities/documentation-manager/environment"
)
// Used when building per
// -ldflags "-X main.version=$app_version -X main.build=$(due --iso-8601 | tr -d "-" )"
var (
version string = "dev"
build string = "dev"
mnemonic string = "docman"
)
/**
*/
func main() {
defer func() {
if r := recover(); r != nil &&
r != environment.ExitWithCodeSymbol {
panic(r)
}
environment.Exit()
}()
commands.Execute(environment.InfoStruct{
Version: version,
Build: build,
Mnemonic: mnemonic,
})
}
// Copyright 2023 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<style>
body {
background-color: #ffffff;
}
</style>
<title>Download Portal schukai GmbH</title>
</head>
<body>
<div class="d-flex flex-column align-items-center justify-content-center"
style="height:100vh;">
<div class="text-center">
<a href="https://www.schukai.com" class="text-decoration-none text-white text-decoration"><img
src="https://cdn.alvine.io/image/logo/schukai-rot.svg" width="300px"></a>
<br>
<div class="card mt-5">
<div class="card-header">
DocMan
</div>
<ul class="list-group">
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./docman-linux-386">docman-linux-386</a></li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./docman-linux-amd64">docman-linux-amd64</a></li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./docman-linux-arm">docman-linux-arm</a></li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./docman-linux-arm64">docman-linux-arm64</a></li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./docman-windows">docman-windows</a></li>
</ul>
</div>
<p class="mt-5">
<a href="https://about.schukai.com/de/impressum/" class="text-decoration-none text-decoration"
style="color:#c10000">Imprint</a></p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
</body>
</html>
#!/usr/bin/env bash
set -x
SOURCE_PATH=$1
BUILD_PATH=$2
COMPONENT_SLUG=$3
GO_RELEASE_PACKAGE_NAME=$4
PROJECT_VERSION=$5
PROJECT_BUILD_DATE=$6
platforms=$(go tool dist list)
included_os=("linux" "windows")
# define a list of excluded architectures
included_arch=("amd64" "arm64")
cd $SOURCE_PATH || exit 1
# Run and build loop through all platforms (except excluded ones)
for platform in $platforms; do
# GOOS und GOARCH Variablen setzen
export GOOS=$(echo $platform | cut -d'/' -f1)
export GOARCH=$(echo $platform | cut -d'/' -f2)
if [[ ! "${included_os[@]}" =~ "$GOOS" ]]; then
echo "Skipping excluded platform: $GOOS"
continue
fi
if [[ ! "${included_arch[@]}" =~ "$GOARCH" ]]; then
echo "Skipping excluded architecture: $GOARCH"
continue
fi
echo "============================================"
echo "Building for $GOOS/$GOARCH"
output_name=$BUILD_PATH$COMPONENT_SLUG-$GOOS-$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOFLAGS= GOWORK=off GO111MODULE=on GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X $GO_RELEASE_PACKAGE_NAME.version=$PROJECT_VERSION -X $GO_RELEASE_PACKAGE_NAME.build=$PROJECT_BUILD_DATE" -o $output_name
if [ $? -ne 0 ]; then
echo "An error has occurred! $output_name build failed."
echo "============================================"
fi
done
cd - || exit 1
#!/bin/bash
# shellcheck shell=bash
$(command -v aws) s3 ls --recursive s3://doc.alvine.io/de/ --region eu-central-1 > "$(THIS_DIR)s3-temp/inventory.txt"
\ No newline at end of file
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm VagaRound
mktextfm VagaRound
mktextfm VagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
mktextfm QTVagaRound
development/examples/example1/out/my-1_1.png

1006 B