knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.58k stars 280 forks source link

Refactor for easier customization #821

Open Peterragheb opened 3 months ago

Peterragheb commented 3 months ago

Scribe version

4.29.0

Your question

I'm wondering it's possible to do some code refactoring to allow easier customization

for example in the GenerateDocumentation command you instantiate the Writer class using the new keyword. Why not use the service container to instantiate it this way it would be easier to custom bind it. (of course there's a lot of other options like adding it to the config file but I think the container is the fastest and easiest solution)

Same for instantiating the CustomTranslationsLoader in the ScribeServiceProvider.

Btw these are the classes I had to customize in order to get the localization to work the way I want it to. This includes:

Docs

shalvah commented 3 months ago

Sure, PR welcome. In general, I didn't go with the approach of using the Laravel container because I wanted it to be easily testable in isolation.

Peterragheb commented 3 months ago

@shalvah here's the PR https://github.com/knuckleswtf/scribe/pull/822

Btw I think the localization can be improved a bit.

let me know if you're okay with that and I'll work on a PR

shalvah commented 3 months ago

If you can make it work while still making sense for the end user and not having too much maintenance overhead, sure 👍