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

Support --config flag to specify config file #472

Merged

Conversation

mooseh
Copy link
Contributor

@mooseh mooseh commented May 19, 2022

Added Ability to use different configs

This pull request is the quickest route to "multiple documentation areas"

Preparation

copy config/scribe.php to another config name e.g config/scribe_admins.php

its at the users discression how they generate the docs but I found static with my own controller way more useful
here are the config options I used

    'type' => 'static',
    'static' => [
        'output_path' => 'resources/views/admin/docs',
    ],
    'laravel' => [
        'add_routes' => false,
        'docs_url' => '/admin/docs',
   ]
                

Usage

php artisan scribe:generate --config=scribe_admins

Notes

I know these is a very very small amount of work added and I'm sure there is more that could be added to make this more functional and smooth but just adding this option has helped me out a massive amount and I feel it could be a massive feature for so many people using this package.
for me the simplest route was to add a second static config like scribe_admins and have add my own routes and controllers to handle serving these generated assets.

like so:

        //documentation
        Route::group(['prefix' => 'docs'], function(){
            Route::get('/', 'DocumentationController@webpage');
            Route::get('openapi', 'DocumentationController@openapi');
            Route::get('postman', 'DocumentationController@postman');
        });

        //Admin documentation
        Route::group(['prefix' => 'admin/docs'], function(){
            Route::get('/', 'DocumentationController@adminWebpage');
            Route::get('openapi', 'DocumentationController@adminOpenapi');
            Route::get('postman', 'DocumentationController@adminPostman');
        });

known issues

Assets are a bit of a tricky one with static doc generation, there are so many ways around this, but my quickest fix was to add them on the fly if they didn't exist in the controller like so.

        File::copyDirectory(resource_path("views/docs/js"), public_path('js'));
        File::copyDirectory(resource_path("views/docs/css"), public_path('css'));
        return view('docs.index');       

Also I looked for the docs folder so I could contribute to the documentation without such luck?

Known Issues / Tickets

#471

the Commits

sorry about the mess I added an ability to use ignore_hidden which I needed to undo in my master branch in order to send this PR.

@shalvah
Copy link
Contributor

shalvah commented May 21, 2022

Docs are at https://github.com/knuckleswtf/scribe-docs. Or you can go to the docs page at https://scribe.knuckles.wtf/laravel/reference/config and click "Edit this page" at the bottom.

@shalvah
Copy link
Contributor

shalvah commented May 21, 2022

Yes, the assets might be tricky, but a recent PR added assets_directory config path, which might make it pretty straightforward. However, it's only for laravel type. I'll look into what's involved for the rest.

For laravel type, though

@shalvah shalvah changed the title Feature/add another config ability Add --config flag to specify config file. May 21, 2022
@shalvah shalvah changed the title Add --config flag to specify config file. Support--config flag to specify config file May 21, 2022
@shalvah shalvah changed the title Support--config flag to specify config file Support --config flag to specify config file May 21, 2022
@shalvah shalvah merged commit 77cba39 into knuckleswtf:master May 21, 2022
@shalvah
Copy link
Contributor

shalvah commented May 22, 2022

Never mind. I've released 3.29.1 that supports multiple docs. The command will also use a different directory for assets and Markdown files (.scribe -> .scribe_admin). See https://scribe.knuckles.wtf/laravel/generating#generating-multiple-docs

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