Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Proposal #3948: Enhance README Generation #3950

Merged
merged 18 commits into from
Oct 2, 2024
Merged

Conversation

Xinlu-Y
Copy link
Collaborator

@Xinlu-Y Xinlu-Y commented Sep 3, 2024

This PR implements the design outlined in proposal #3948. The main objective is to ensure that the scope and motivation are included in both the SystemInformation and the generated README files.

Key Updates:

  • Optional Subsections: Motivation an Purpose are now optional subsections under introInfo.
  • 'What' Section: background and scope are now optional subsections under whatInfo.

Closes: #3948, #3159, #3248, #3971

Resolved GHC warnings by fixing name shadowing issues and removing redundant bracket.

Added new fields into sglPend.
Copy link
Owner

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your actual changes are actually fine - but you are doing them against a bad design... so the right thing to do is to first fix the design, then apply these changes again.

Now, if you want, I would be fine with accepting the code as-is and have you fix the design after. I suspect that that is actually more work!

@@ -52,6 +52,10 @@ type CaseName = String
type ExamplePurpose = String
-- | Description of example
type ExampleDescr = String
-- | Motivation of example
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is good that you are following the established pattern in this code, the problem is that the pattern is wrong... in that GOOL shouldn't know anything at all about 'examples'.

The real problem isn't these types, but ReadMeInfo which shouldn't be defined inside GOOL at all!

So I think the first step of the implementation, as a separate PR, would be to first fix this and move this information out of GOOL.

@@ -150,6 +150,10 @@ genPackage unRepr = do
(foldlSent $ purpose $ codeSpec g)
bckgrnd = show $ sentenceDoc db Implementation OneLine
(foldlSent $ background $ codeSpec g)
mtvtn = show $ sentenceDoc db Implementation OneLine
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that same refactor, I think all the stuff that concerns README generation should be moved out of this file. It could go into Language/Drasil/Code/Imperative/Generator/README.

@@ -47,6 +47,10 @@ data CodeSpec where
purpose :: Purpose,
-- | Example Background.
background :: Background,
-- | Example Scope.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this information should be in CodeSpec either. It is fine to have it in SystemInformation though.

@Xinlu-Y
Copy link
Collaborator Author

Xinlu-Y commented Sep 9, 2024

I got stuck after representing the fields purpose, background, motivation, and scope as ConceptInstances. By doing this, these pieces of information are stored in the sysinfodb, which is then copied into CodeSpec. However, in the genPackage function, I need assistance with retrieving a ConceptInstance by its UID. Any guidance from those familiar with this process would be appreciated.

@JacquesCarette
Copy link
Owner

If @balacij can't help you tonight, then I will be at McMaster tomorrow and should be able to help (likely time: early afternoon).

- Used the generated `sysInfo` lens to access nested fields in `SystemInformation` from `CodeSpec`.
@@ -40,7 +41,7 @@ unmodularDesc = do
implTypeStr Program = "program"
implTypeStr Library = "library"
return $ show $ sentenceDoc (sysinfodb spec) Implementation OneLine $ capSent $
foldlSent ([S "a", S (implTypeStr (implType g)), S "to"] ++ purpose spec)
foldlSent ([S "a", S (implTypeStr (implType g)), S "to"] ++ codeSpec g ^. sysInfo .purpose)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to "double lens" (i.e. .sysInfo .purpose). If you make the right instance, .purpose should be enough.

@@ -41,36 +40,3 @@ class AuxiliarySym r where

auxHelperDoc :: r (AuxHelper r) -> Doc
auxFromData :: FilePath -> Doc -> r (Auxiliary r)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is a nice clean-up!

import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..),PackageSym(..),
AuxiliarySym(..))
import Language.Drasil.Code.Imperative.GOOL.ClassInterface (PackageSym(..), AuxiliarySym(..))
import Language.Drasil.Code.Imperative.ReadMe.Import (ReadMeInfo(..))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain to me why all the language renderers need access to ReadMeInfo?

@@ -5,7 +5,7 @@ module Language.Drasil.Code.Imperative.WriteReadMe (
import Language.Drasil.Choices (ImplementationType(..))
import Language.Drasil.Printers (makeMd, introInfo, verInfo, unsupOS,
extLibSec, instDoc, endNote, whatInfo)
import Language.Drasil.Code.Imperative.GOOL.ClassInterface (ReadMeInfo(..))
import Language.Drasil.Code.Imperative.ReadMe.Import (ReadMeInfo(..))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much better!

@@ -70,7 +67,9 @@ data CodeSpec where
-- automatically define.
mods :: [Mod], -- medium hack
-- | The database of all chunks used in the problem.
sysinfodb :: ChunkDB
sysinfodb :: ChunkDB,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the aim was to rename this CodeSpec to OldCodeSpec and then make CodeSpec has just 2 fields?

@JacquesCarette
Copy link
Owner

@Xinlu-Y can you please fix the conflict that was recently created?

- Extracted parts of the original `CodeSpec` into a new` OldCodeSpec` data type.
- Used `makeClassyFor`  to create accessor functions such as `pNameO`, `authorsO`, `inputsO`, etc., which are now used to access corresponding fields in `OldCodeSpec`.
- Generated the `oldCodeSpec` lens, which allows easy access and modification of `OldCodeSpec` fields from a `CodeSpec` instance.
- Updated `CodeSpec` to hold both `SystemInformation` and a reference to `OldCodeSpec`.
- Modified related functions (e.g., `codeSpec`, `oldcodeSpec`) .
- Introduced `makeClassy` to generate the `HasSystemInformation` type class and associated lenses for the `SystemInformation` data structure.
- Updated `CodeSpec` to use the `HasSystemInformation` type class.
@Xinlu-Y
Copy link
Collaborator Author

Xinlu-Y commented Oct 2, 2024

@JacquesCarette Dr. Carette, Could you please review the latest changes when you have time? I have addressed the earlier feedback and resolved the conflicts. Thank you!

@JacquesCarette JacquesCarette merged commit 8490ac2 into main Oct 2, 2024
5 checks passed
@balacij balacij deleted the expandREADME branch October 3, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Scope and Motivation Fields and Defining the Role of the What Section in README Files
2 participants