Skip to content

Commit

Permalink
Merge pull request #2263 from mahrud/quickfix/help
Browse files Browse the repository at this point in the history
fix documentation of shared symbols
  • Loading branch information
DanGrayson authored Nov 7, 2021
2 parents 3f0f4d2 + 3b6ac67 commit 7a4e964
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
4 changes: 2 additions & 2 deletions M2/Macaulay2/m2/document.m2
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ makeDocumentTag String := opts -> key -> (
-- correct its package, if it is incorrect (e.g. truncate, quotient)
-- TODO: can this be modified to fix the tag in-place? then we would only need to
-- fix the tag in (validate, TO), rather than also in (info, TO) and (html, TO).
fixup DocumentTag := DocumentTag => tag -> makeDocumentTag(
if instance(key := tag.Key, String) then return tag else key, Package => package key)
fixup DocumentTag := DocumentTag => tag -> (
if (rawdoc := fetchAnyRawDocumentation tag) =!= null then rawdoc.DocumentTag else tag)

-----------------------------------------------------------------------------
-- formatting document tags
Expand Down
37 changes: 9 additions & 28 deletions M2/Macaulay2/m2/help.m2
Original file line number Diff line number Diff line change
Expand Up @@ -387,37 +387,18 @@ getBody := (key, tag, rawdoc) -> (

-- TODO: help symbol% before Macaulay2Doc is installed doesn't work
help = method(Dispatch => Thing)
-- overview nodes and formatted documentation keys
help String := key -> (
rawdoc := fetchAnyRawDocumentation makeDocumentTag key;
tag := getOption(rawdoc, symbol DocumentTag);
if tag.?Key and tag.Key =!= key then help tag.Key
else if isGlobalSymbol key then help getGlobalSymbol key
else getBody(key, tag, rawdoc))
help DocumentTag := tag -> (
rawdoc := fetchAnyRawDocumentation tag;
tag = if rawdoc =!= null then rawdoc.DocumentTag else tag;
getBody(tag.Key, tag, rawdoc))

-- Methods
help Sequence := key -> (
if key === () then return if inDebugger then debuggerUsageMessage else help "initial help";
-- TODO: make this work with hook strategies; e.g. (foo, ZZ, Strategy => Default)
if lookup key === null then error("expected ", toString key, " to be a method");
rawdoc := fetchAnyRawDocumentation makeDocumentTag key;
tag := getOption(rawdoc, symbol DocumentTag);
getBody(key, tag, rawdoc))

-- Options
help Array := key -> (
verifyKey key;
rawdoc := fetchAnyRawDocumentation makeDocumentTag key;
tag := getOption(rawdoc, symbol DocumentTag);
getBody(key, tag, rawdoc))

-- everything else: Symbols, Types, ScriptedFunctors, Functions, Keywords, and Packages
help Symbol := key -> (
rawdoc := fetchAnyRawDocumentation makeDocumentTag key;
tag := getOption(rawdoc, symbol DocumentTag);
getBody(key, tag, rawdoc))
if key =!= () then help makeDocumentTag key else
if inDebugger then debuggerUsageMessage else help "initial help")

help DocumentTag := tag -> help tag.Key
help String :=
help Symbol :=
help Array :=
help Thing := x -> help makeDocumentTag x
help List := l -> DIV between(HR{}, help \ l)
help ZZ := i -> seeAbout(help, i)
Expand Down

0 comments on commit 7a4e964

Please sign in to comment.