[ doc ] return module header docs

This commit is contained in:
Guillaume Allais 2022-03-08 18:14:40 +00:00 committed by G. Allais
parent 51eb854a60
commit 14f2196d15
7 changed files with 31 additions and 3 deletions

View File

@ -576,7 +576,11 @@ getDocs (APTerm ptm) = getDocsForPTerm ptm
getDocs (Symbol k) = pure $ getDocsForSymbol k
getDocs (Bracket IdiomBrackets) = pure "Idiom brackets (cf. manual)"
getDocs (Keyword k) = pure $ getDocsForKeyword k
getDocs (AModule mod) = do
syn <- get Syn
let Just modDoc = lookup mod (modDocstrings syn)
| _ => throw (ModuleNotFound replFC mod)
pure (pretty modDoc)
summarise : {auto c : Ref Ctxt Defs} ->
{auto s : Ref Syn SyntaxInfo} ->

View File

@ -2061,7 +2061,8 @@ docArgCmd parseCmd command doc = (names, DocArg, doc, parse)
symbol ":"
runParseCmd parseCmd
dir <- mustWork $
Keyword <$> anyKeyword
AModule <$ keyword "module" <*> moduleIdent -- must be before Keyword to not be captured
<|> Keyword <$> anyKeyword
<|> Symbol <$> (anyReservedSymbol <* eoi
<|> parens (Virtual Interactive) anyReservedSymbol <* eoi)
<|> Bracket <$> (IdiomBrackets <$ symbol "[|" <* symbol "|]")

View File

@ -599,6 +599,8 @@ data DocDirective : Type where
Bracket : BracketType -> DocDirective
||| An arbitrary PTerm
APTerm : PTerm -> DocDirective
||| A module name
AModule : ModuleIdent -> DocDirective
public export
data REPLCmd : Type where

View File

@ -207,7 +207,7 @@ idrisTestsReflection = MkTestPool "Quotation and Reflection" [] Nothing
idrisTests : TestPool
idrisTests = MkTestPool "Misc" [] Nothing
-- Documentation strings
["docs001", "docs002", "docs003", "docs004",
["docs001", "docs002", "docs003", "docs004", "docs005",
-- Eta equality
"eta001",
-- Modules and imports

View File

@ -0,0 +1,16 @@
Main> Imported module Data.Vect.AtIndex
Main> Indexing Vectors.
`Elem` proofs give existential quantification that a given element
*is* in the list, but not where in the list it is! Here we give a
predicate that presents proof that a given index of a vector,
given by a `Fin` instance, will return a certain element.
Two decidable decision procedures are presented:
1. Check that a given index points to the provided element in the
presented vector.
2. Find the element at the given index in the presented vector.
Main>
Bye for now!

View File

@ -0,0 +1,2 @@
:module Data.Vect.AtIndex
:doc module Data.Vect.AtIndex

3
tests/idris2/docs005/run Executable file
View File

@ -0,0 +1,3 @@
rm -rf build
$1 --no-color --console-width 0 --no-banner < input