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

Post life cycle #244

Closed
wants to merge 2 commits into from
Closed

Post life cycle #244

wants to merge 2 commits into from

Conversation

hmf
Copy link

@hmf hmf commented Dec 12, 2019

Pull request for #213. Note that onWatchIterationEnd not implemented.

@hmf hmf closed this Dec 12, 2019
Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution! I just did a quickly review, will need a closer look another time

import mdoc._
import mdoc.internal.cli.{Exit, Settings}
Copy link
Member

Choose a reason for hiding this comment

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

Settings can’t be exposed in the public api since it’s internal. We could add a public interface on the class if that helps

Copy link
Author

Choose a reason for hiding this comment

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

@olafurpg Apologies for closing this but the CI/CD failed. In particular one tests assumes that the files are processed in a given order. Need to correct this.

Settings are not required so I will remove it.

Copy link
Member

Choose a reason for hiding this comment

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

You can add MainSettings as an argument

https://github.com/scalameta/mdoc/blob/cf4aa2872e44a1abef1badbfe0544bf39d1a554c/mdoc/src/main/scala/mdoc/MainSettings.scala

We can add public methods down the road to access fields on the private Settings

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we can add a abstract class Settings in the public mdoc API and pass that in even if it has no public members for now. It's desirable to pass in one parameter just so we can pass in more information in the future without breaking the public API

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand the use of MainSettings. Settings does not extend this class. Note that I call onStart method in MainOps. Can you explain?

Copy link
Member

Choose a reason for hiding this comment

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

Settings is a case class which gets auto generated methods like “copy” that break binary compatibility on removal/addition of fields. This makes case classes essentially unsuitable for public APIs unless you’re certain you will never need to add/remove a field.

MainSettings is just a thin wrapper around the case class that has a stable api that we can evolve in a binary compatible way.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the explanation. MainSettingsis now being used. I have tried to make as few changes as possible. They are basically limited to MainOps. Not too happy with it because I would have liked to make the calls within the MainOps.runmethod. However this would entail changing the parameters of the constructor or run (Context is used in many places and my not be the best change).

Please see #245

import scala.meta.inputs.Input
import scala.meta.io.AbsolutePath
import scala.collection.JavaConverters._
import scala.meta.io.RelativePath

trait PostModifier {
val name: String
def onStart(settings: Settings): Unit
Copy link
Member

Choose a reason for hiding this comment

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

These need to have default implementations for backwards compatibility

Copy link
Author

Choose a reason for hiding this comment

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

Ok. Will do. Will a simple return of () do?

Apologies for the newbie questions.

I as planning to make another pull request. Should I or do I keep working here? If I do open a new one, their seem to be a "review pull " option. Should I use that instead?

Copy link
Member

Choose a reason for hiding this comment

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

: Unit = () is a fine default implementation

Copy link
Author

Choose a reason for hiding this comment

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

Done

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.

2 participants