We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Verified Commit f3b51448 authored by Camil Staps's avatar Camil Staps 🚀

Initial setup of project: generate HTML file for each module

parent 5ac8eedd
Pipeline #14385 failed with stage
in 55 seconds
*.exe
*.abc
*.o
*.prj
cleandoc
clean-compiler/
build:
image: "camilstaps/clean:nightly"
before_script:
- install_clean_nightly.sh base lib-platform
- apt-get update -qq
- apt-get install -y -qq build-essential subversion
script:
- make -C src
definition module Clean.Doc.ModuleCollection
from Clean.ModuleFinder import :: ModuleFindingOptions
from Data.Error import :: MaybeError
from Data.Maybe import :: Maybe
from System.FilePath import :: FilePath
:: ModuleCollection :== [ModuleDescription]
:: ModuleDescription =
{ mod_name :: !String
, mod_description :: !Maybe String
}
collectModule :: !ModuleFindingOptions !FilePath !*World
-> *(!MaybeError String ModuleDescription, !*World)
implementation module Clean.Doc.ModuleCollection
import StdFile
import StdMisc
import Clean.Doc
import Clean.ModuleFinder
import Clean.Parse
import Clean.Parse.Comments
import Control.Monad
import Data.Either
import Data.Error
import Data.Functor
import Data.Maybe
from syntax import
:: Ident{id_name},
:: Module{mod_defs,mod_ident}
collectModule :: !ModuleFindingOptions !FilePath !*World
-> *(!MaybeError String ModuleDescription, !*World)
collectModule mfo fp w
# (comments,w) = scanComments fp w
# (dcl,w) = readModule fp w
| isError dcl = (Error (fromError dcl), w)
# (dcl,_) = fromOk dcl
# (mod,dcldefs,documentation) = (dcl, dcl.mod_defs, case comments of
Error _ -> emptyCollectedComments
Ok comments -> collectComments comments dcl)
# moddoc = moddoc
with
moddoc :: Maybe ModuleDoc
moddoc = case parseDoc <$> getComment mod documentation of
Just (Right (doc,_)) -> Just doc
_ -> Nothing
# moddesc =
{ mod_name = mod.mod_ident.id_name
, mod_description = docDescription =<< moddoc
}
= (Ok moddesc, w)
definition module Clean.Doc.ModuleCollection.HTML
from System.FilePath import :: FilePath
from Text.HTML import :: HtmlTag
from Clean.Doc.ModuleCollection import :: ModuleCollection, :: ModuleDescription
:: HTMLSite
generateHTML :: !ModuleCollection -> HTMLSite
/**
* Write a HTML site to disk.
*
* @param The root directory.
* If it does not exist, it will be created.
* If it exists, all contents will be deleted.
* @param The site
* @result A list of errors occurred, in human-readable format
*/
writeHTMLSite :: !FilePath !HTMLSite !*World -> *(![String], !*World)
implementation module Clean.Doc.ModuleCollection.HTML
import StdFile
import StdList
import StdTuple
import Control.Applicative
import Data.Error
from Data.Func import $, mapSt, instance Functor ((->) a)
import Data.Functor
import Data.List
import System.Directory
import System.File
import System.FilePath
import Text.HTML
import Clean.Doc.ModuleCollection
:: HTMLSite :== [(FilePath, HtmlTag)]
generateHTML :: !ModuleCollection -> HTMLSite
generateHTML mcoll = map moduleFile mcoll
where
moduleFile :: !ModuleDescription -> (FilePath, HtmlTag)
moduleFile m = ("mod" </> m.mod_name +++ ".html", html)
where
html = DivTag [] $ catMaybes
[ Just $ H1Tag [] [Text m.mod_name]
, DivTag [] <$> pure <$> Text <$> m.mod_description
]
writeHTMLSite :: !FilePath !HTMLSite !*World -> *(![String], !*World)
writeHTMLSite root site w
# (_,w) = recursiveDelete root w
# (errs,w) = mapSt (uncurry handle) site w
= (flatten errs,w)
where
handle :: !FilePath !HtmlTag !*World -> *(![String], !*World)
handle fp contents w
# fp = root </> fp
# (err,w) = ensureDirectoryExists (takeDirectory fp) w
| isError err = ([snd (fromError err)], w)
# (err,w) = writeFile fp (toString contents) w
| isError err = ([toString (fromError err)], w)
= ([], w)
SHELL:=/bin/bash
BIN:=cleandoc
.PHONY: all clean
all: $(BIN)
$(BIN): %: %.prj clean-compiler .FORCE
cpm $<
$(addsuffix .prj,$(BIN)): %.prj: %.prj.default
cp $^ $@
clean-compiler:
svn checkout -r 3043 https://svn.cs.ru.nl/repos/clean-compiler/branches/itask/ clean-compiler
$(MAKE) -j -C clean-compiler/main/Unix
$(MAKE) -j -C clean-compiler/backendC/CleanCompilerSources -f Makefile.linux64
ln -s ../../backendC/CleanCompilerSources/backend.a clean-compiler/backend/Clean\ System\ Files/backend_library
clean:
shopt -s globstar; $(RM) -r **/Clean\ System\ Files $(BIN) $(addsuffix .prj,$(BIN))
.FORCE:
module cleandoc
import StdFile
import StdList
import StdTuple
import Clean.ModuleFinder
import Clean.Parse
import Data.Error
from Data.Func import $, mapSt
import System.CommandLine
import System.Options
import Text
import Text.HTML
import Clean.Doc.ModuleCollection
import Clean.Doc.ModuleCollection.HTML
Start w
# ([prog:args],w) = getCommandLine w
# (opts,w) = defaultModuleFindingOptions w
# opts & include_libraries = []
# opts = parseOptions (WithHelp True moduleFindingOptionDescription) args opts
| isError opts = exit (fromError opts) w
# opts = fromOk opts
# (errs,fps,w) = findAllModules opts w
| errs=:[_:_] = exit (map snd errs) w
# (modcoll,w) = mapSt (collectModule opts) fps w
| any isError modcoll = exit [e \\ Error e <- modcoll] w
# modcoll = map fromOk modcoll
# html = generateHTML modcoll
# (errs,w) = writeHTMLSite "doc" html w
| errs=:[_:_] = exit errs w
= w
exit :: ![String] !*World -> *World
exit errs w
# err = stderr <<< join "\n" errs <<< "\n"
# (_,w) = fclose err w
# w = setReturnCode -1 w
= w
Version: 1.4
Global
ProjectRoot: .
Target: StdEnv
Exec: {Project}/cleandoc
CodeGen
CheckStacks: False
CheckIndexes: True
Application
HeapSize: 209715200
StackSize: 512000
ExtraMemory: 8192
IntialHeapSize: 204800
HeapSizeMultiplier: 4096
ShowExecutionTime: False
ShowGC: False
ShowStackSize: False
MarkingCollector: False
DisableRTSFlags: True
StandardRuntimeEnv: True
Profile
Memory: False
MemoryMinimumHeapSize: 0
Time: False
Stack: False
Dynamics: False
GenericFusion: False
DescExL: False
Output
Output: NoConsole
Font: Monaco
FontSize: 9
WriteStdErr: False
Link
LinkMethod: Static
GenerateRelocations: False
GenerateSymbolTable: False
GenerateLinkMap: False
LinkResources: False
ResourceSource:
GenerateDLL: False
ExportedNames:
Paths
Path: {Project}
Path: {Project}*clean-compiler*frontend
Path: {Project}*clean-compiler*backend
Path: {Project}*clean-compiler*main
Path: {Project}*clean-compiler*main*Unix
Path: {Application}*lib*Platform
Path: {Application}*lib*Platform*Deprecated*ArgEnv
Precompile:
Postlink:
MainModule
Name: cleandoc
Dir: {Project}
Compiler
NeverMemoryProfile: False
NeverTimeProfile: False
StrictnessAnalysis: True
ListTypes: StrictExportTypes
ListAttributes: True
Warnings: True
Verbose: True
ReadableABC: False
ReuseUniqueNodes: True
Fusion: False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment