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

feat: Store documentation file on a configurable directory #152

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

hans-thomas
Copy link
Contributor

@hans-thomas hans-thomas commented Dec 13, 2024

Hi, it adds the ability to store the generated documentation file in a configurable directory.

TODO list:

  • Local and Storage drivers should have new config, named directory with the default value documentations
  • the production_path config for Local and Storage drivers should be renamed to base_file_name with the default value documentation (without .json extension)
  • documentation file extension should be automatically extended by the .json extension
  • Local driver should check if directory exists and create it if not (on documentation saving)
  • Storage driver should create storage directory only for non Cloud drivers (on documentation saving)
  • Config version should be increased to force developers republish package config

@DenTray
Copy link
Collaborator

DenTray commented Dec 16, 2024

@hans-thomas I've updated task description, please add required changes accordingly the new task description (please feel free to open few PRs if you can divide task for small subtasks without breaking the package work)

@DenTray
Copy link
Collaborator

DenTray commented Dec 16, 2024

@hans-thomas please do not use autoclosing issues as we need to test task before closing

@hans-thomas
Copy link
Contributor Author

Hi @DenTray, would you please review this PR?

@hans-thomas hans-thomas requested a review from DenTray January 21, 2025 08:23

if (empty($this->prodFilePath)) {
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
$directory = (str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change but I can't understand the difference.


if (empty($this->prodFilePath)) {
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
Copy link
Collaborator

Choose a reason for hiding this comment

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

as you already did the same in the local driver, let's move this logic to the BaseDriver class

Suggested change
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
$directory = (str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR))

Force set documentation directory as empty for AutoDocControllerTest;
@hans-thomas hans-thomas force-pushed the doc-file-on-configurable-dir branch from ee90fc7 to cef046b Compare February 2, 2025 17:53
@hans-thomas hans-thomas requested a review from DenTray February 2, 2025 17:54

if (empty($this->prodFilePath)) {
$directory = (str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR))
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure this logic required for the Storage driver as it works correctly for all next cases:

  • Storage::put('file.txt', 'content')
  • Storage::put('/path/file.txt', 'content')
  • Storage::put('path/file.txt', 'content')
  • Storage::put('/file.txt', 'content')
  • Storage::put('//file.txt', 'content')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That logic was preventing this case:

Storage::put('documentations//documentation.json', 'content')

However, it's handling this case correctly, too.

$driver = new LocalDriver();
$driver->saveTmpData(self::$tmpData);

$this->assertFileExists(self::$tmpDocumentationFilePath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
$this->assertFileExists(self::$tmpDocumentationFilePath);
$this->assertFileExists(storage_path('documentations/documentation.json'));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These static properties are used several times in this class and I believe they are beneficial to keep tests simpler and improve the readability.

Copy link

sonarqubecloud bot commented Feb 8, 2025

@hans-thomas hans-thomas requested a review from DenTray February 20, 2025 06:56
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