Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

Allow documenting methods from another package #1490

Closed mahrud closed 3 years ago

mahrud commented 4 years ago

See this "kludge" line: https://github.com/Macaulay2/M2/blob/2eb5731e107c64c5574228207487da6d2edb5e48/M2/Macaulay2/m2/document.m2#L140-L145 Removing that line would break Schubert2.

_Originally posted by @mahrud in https://github.com/Macaulay2/M2/pull/1454#discussion_r485214705_

DanGrayson commented 4 years ago

More precisely, make it possible to tell, for method functions, what package they are really from. We still do not want one package documenting code from another.

mahrud commented 4 years ago

We still do not want one package documenting code from another.

Why? Both Macaulay2Doc and Text document code from Core. Classic installs (matrix, String) and (ideal, String), which are methods defined in Core, and Macaulay2Doc documents a few nodes on primary decomposition coming from PrimaryDecomposition (see ov_ideal.m2).

These are just the ones I know.

More precisely, make it possible to tell, for method functions, what package they are really from.

This part is easy, e.g.:

i3 : locate (matrix, String)
o3 = (../../Macaulay2/packages/Classic.m2, 37, 32, 38, 45, 38, 43)
DanGrayson commented 4 years ago

We still do not want one package documenting code from another.

Why? Both Macaulay2Doc and Text document code from Core.

That's the unique exception, grandfathered in. We can fix that by merging the two.

Classic installs (matrix, String) and (ideal, String), which are methods defined in Core,

No, they're also from Classic:

Macaulay2, version 1.16
with packages: ConwayPolynomials, Elimination, IntegralClosure, InverseSystems, LLLBases, MinimalPrimes, PrimaryDecomposition, ReesAlgebra, TangentCone, Truncations

i1 : code(matrix,String)

o1 = -- code for method: matrix(String)
     /Applications/Macaulay2-1.16/share/Macaulay2/Classic.m2:37:33-38:46: --source code:
     matrix String := Matrix => opts -> 
                       matrix_opts % arrayPolyP : nonspaceAnalyzer

and Macaulay2Doc documents a few nodes on primary decomposition coming from PrimaryDecomposition (see ov_ideal.m2).

That would give an error. If not, it's a bug.

These are just the ones I know.

More precisely, make it possible to tell, for method functions, what package they are really from.

This part is easy, e.g.:

i3 : locate (matrix, String)
o3 = (../../Macaulay2/packages/Classic.m2, 37, 32, 38, 45, 38, 43)

... unless the file revealed that way is not part of a package. How would we tell?

mahrud commented 4 years ago

No, they're also from Classic:

ideal, matrix, and String are all defined in Core:

i10 : package (ideal, String)

o10 = Core

o10 : Package

... unless the file revealed that way is not part of a package. How would we tell?

Make sure every file is part of a package, otherwise they can't be documented.

DanGrayson commented 4 years ago

... unless the file revealed that way is not part of a package. How would we tell?

Make sure every file is part of a package, otherwise they can't be documented.

Yes, but we should say how to do that.

Here's one way. Modify the code that sets loadedFiles so it includes the currentPackage as part of the info:

i5 : peek loadedFiles 

o5 = MutableHashTable{0 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/command.m2                                                     }
                      1 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/classes.m2
                      2 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/option.m2
                      3 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/methods.m2
                      4 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/autoload.m2
                      5 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/system.m2
                      6 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/run.m2
                      7 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/profile.m2
                      8 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/debugging.m2
                      9 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/remember.m2
                      10 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/set.m2
                      11 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/files.m2
                      12 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/fold.m2
                      13 => /Applications/Macaulay2-1.16/share/Macaulay2/Core/max.m2
...