Skip to content

Commit

Permalink
Merge pull request #65 from smartbooster/documentation_render_markdown
Browse files Browse the repository at this point in the history
Add markdown documentation rendering feature
  • Loading branch information
mathieu-ducrot authored Jun 12, 2024
2 parents 8dcf0a5 + 3ef566e commit addeff4
Show file tree
Hide file tree
Showing 20 changed files with 497 additions and 103 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
CHANGELOG
===================
## v2.4.0 - (2024-06-12)
### Added
- `DocumentationController::renderMarkdown` action to render markdown documentation files stored in the **/documentation** directory
- `RouteLoader` + `RouteCompilerPass` to auto generate routing for each markdown files
- `markdown.html.twig` template to render the markdown content as html
- `_documentation.scss` **.sb-documentation** class based on **@tailwindcss/typography** plugin
- `_tailwind.scss` dedicated smartbooster tailwind override or missing class from unalign tailwind version

### Changed
- `services.yaml` reorder services declaration by alphabetical namespace subject

### Fixed
- `DocumentationController::email` use twig injected service to render the response content so no extra controller extending DocumentationController is
needed.
- `standard_layout.html.twig` add missing extra padding on **sonata_page_content_header** when there is an env_banner

### Removed
- `/config/routing.yaml` deleted in favor of route being available through the `RouteLoader` (so when updating to this version you no longer need to
import it)

## v2.3.0 - (2024-06-10)
### Added
- `AbstractApiCallAdmin::getOriginChoices` for api call origin filter
Expand Down
27 changes: 26 additions & 1 deletion assets/styles/_documentation.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Legacy doc kept for now
.documentation {
h3 {
font-weight: bold;
Expand All @@ -12,4 +13,28 @@
.test-form {
font-size: 12px;
}
}
}

// Tailwind custom Smartbooster prose styles
.sb-documentation {
@apply prose prose-a:text-info prose-a:no-underline hover:prose-a:underline hover:prose-a:text-info max-w-none inline-block;
h1, h2, h3, h4 {
a {
@apply text-inherit;
}
a:hover {
@apply no-underline;
@apply text-inherit;
}
}
h1, h2 {
a {
@apply font-bold;
}
}
h3, h4 {
a {
@apply font-semibold;
}
}
}
18 changes: 18 additions & 0 deletions assets/styles/_tailwind.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.sb-tailwind {
.ps-0 {
padding-inline-start: 0px;
}
.container-full {
@apply mx-auto w-full;
}
.container-large {
@apply mx-auto w-full;
max-width: 1729px /* Corresponds to full width on a 1920px screen with the vertical scrollbar */
}
.container-medium {
@apply mx-auto w-full max-w-screen-xl; /* 1280px */
}
.container-small {
@apply mx-auto w-full max-w-screen-md; /* 768px */
}
}
2 changes: 2 additions & 0 deletions assets/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@import 'adminlte/variables';
@import 'adminlte/mixins';

@import "tailwind";

@import "variables";
@import "skin";
@import "login";
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"yokai/security-token-bundle": "^3.3",
"sentry/sentry-symfony": "^4.1",
"symfony/expression-language": "^4.4 || ^5.4 || ^6.0",
"smartbooster/core-bundle": "^1.5",
"smartbooster/core-bundle": "^1.6",
"yokai/enum-bundle": "^4.1"
},
"require-dev": {
Expand Down
6 changes: 0 additions & 6 deletions config/routing.yaml

This file was deleted.

199 changes: 107 additions & 92 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
services:
# Admin
admin.batch_log:
class: Smart\SonataBundle\Admin\BatchLogAdmin
arguments:
- ~
- Smart\SonataBundle\Entity\Log\BatchLog
- ~
tags:
- {name: sonata.admin, manager_type: orm, label: dashboard.label_batch_log}
admin.parameter:
class: Smart\SonataBundle\Admin\ParameterAdmin
arguments:
- ~
- Smart\SonataBundle\Entity\Parameter
- ~
- '@Smart\SonataBundle\Enum\ParameterTypeEnum'
- '@Smart\SonataBundle\Logger\HistoryLogger'
tags:
- {name: sonata.admin, manager_type: orm, label: dashboard.label_parameter}

# Admin Extensions
admin.extension.action_delete:
class: Smart\SonataBundle\Admin\Extension\ActionExtension
arguments:
Expand All @@ -11,162 +32,156 @@ services:
- edit
tags:
- { name: sonata.admin.extension, global: true }
admin.extension.action_show:
admin.extension.action_impersonate:
class: Smart\SonataBundle\Admin\Extension\ActionExtension
arguments:
- show
tags:
- { name: sonata.admin.extension, global: true }
admin.extension.encode_password:
class: Smart\SonataBundle\Admin\Extension\EncodePasswordExtension
arguments:
- '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
- 'impersonate'
tags:
- { name: sonata.admin.extension }
admin.extension.action_impersonate:
- {name: sonata.admin.extension}
admin.extension.action_restart_api_call:
class: Smart\SonataBundle\Admin\Extension\ActionExtension
arguments:
- 'impersonate'
- 'restart_api_call'
tags:
- { name: sonata.admin.extension }
- {name: sonata.admin.extension}
admin.extension.action_send_account_creation_email:
class: Smart\SonataBundle\Admin\Extension\ActionExtension
arguments:
- 'send_account_creation_email'
tags:
- { name: sonata.admin.extension }
admin.extension.action_restart_api_call:
admin.extension.action_show:
class: Smart\SonataBundle\Admin\Extension\ActionExtension
arguments:
- 'restart_api_call'
- show
tags:
- {name: sonata.admin.extension}
Smart\SonataBundle\Mailer\EmailProvider:
arguments:
- '@request_stack'
Smart\SonataBundle\Mailer\BaseMailer:
arguments:
- '@Symfony\Component\Mailer\MailerInterface'
- '@Smart\SonataBundle\Mailer\EmailProvider'
- '@Symfony\Contracts\Translation\TranslatorInterface'
- '@Smart\SonataBundle\Logger\HistoryLogger'
Smart\SonataBundle\Controller\Admin\DocumentationController:
tags: ['controller.service_arguments']
Smart\SonataBundle\Controller\AbstractSecurityController:
tags: [ 'controller.service_arguments' ]
arguments:
[ '@yokai_security_token.default_token_manager', '@Smart\SonataBundle\Mailer\BaseMailer', '@translator', '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface', '@Sonata\AdminBundle\Templating\TemplateRegistry', '@Doctrine\ORM\EntityManagerInterface' ]

smart_sonata.parameter_provider:
class: Smart\SonataBundle\Provider\ParameterProvider
public: true
arguments:
- '@Doctrine\ORM\EntityManagerInterface'

Smart\SonataBundle\Provider\ParameterProvider:
public: false
alias: smart_sonata.parameter_provider

smart_sonata.parameter_loader:
class: Smart\SonataBundle\Loader\ParameterLoader
public: true
- {name: sonata.admin.extension, global: true}
admin.extension.encode_password:
class: Smart\SonataBundle\Admin\Extension\EncodePasswordExtension
arguments:
- '@Doctrine\ORM\EntityManagerInterface'

Smart\SonataBundle\Loader\ParameterLoader:
public: false
alias: smart_sonata.parameter_loader
- '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
tags:
- {name: sonata.admin.extension}

# Command
smart_sonata.parameter_load_command:
class: Smart\SonataBundle\Command\ParameterLoadCommand
public: true
arguments:
- '@smart_sonata.parameter_loader'
tags: [ 'console.command' ]

Smart\SonataBundle\Command\ParameterLoadCommand:
public: false
alias: smart_sonata.parameter_load_command

admin.parameter:
class: Smart\SonataBundle\Admin\ParameterAdmin
# Config
Smart\SonataBundle\Config\IniOverrideConfig:
arguments:
- ~
- Smart\SonataBundle\Entity\Parameter
- ~
- '@Smart\SonataBundle\Enum\ParameterTypeEnum'
- '@Smart\SonataBundle\Logger\HistoryLogger'
tags:
- { name: sonata.admin, manager_type: orm, label: dashboard.label_parameter }
- '%env(default::PLATFORM_BATCH_MEMORY)%'

# Controller
Smart\SonataBundle\Controller\AbstractSecurityController:
tags: [ 'controller.service_arguments' ]
arguments:
[ '@yokai_security_token.default_token_manager', '@Smart\SonataBundle\Mailer\BaseMailer', '@translator', '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface', '@Sonata\AdminBundle\Templating\TemplateRegistry', '@Doctrine\ORM\EntityManagerInterface' ]
Smart\SonataBundle\Controller\Admin\DocumentationController:
calls:
- setContainer: [ '@service_container' ]
- setProjectDir: [ "%kernel.project_dir%" ]
- setTwig: [ '@twig' ]
tags: [ 'controller.service_arguments' ]

# DataFixtures
fixture.processor.password:
class: Smart\SonataBundle\DataFixtures\Processor\UserProcessor
arguments:
- '@Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface'
tags:
- { name: fidry_alice_data_fixtures.processor }

security.processor.last_login:
class: Smart\SonataBundle\Security\Processor\LastLoginProcessor
arguments:
- '@doctrine.orm.entity_manager'
# DependencyInjection
# The "Symfony\Component\DependencyInjection\ContainerInterface" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.
# It's not a good way, but it's practical for the moment. It's used in AbstractAdmin::get. Need to replace all get call by injection
Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'

security.subscriber:
class: Smart\SonataBundle\Security\EventSubscriber\SecuritySubscriber
# Enum
Smart\SonataBundle\Enum\ParameterTypeEnum:
arguments:
- '@security.processor.last_login'
- '@translator'
tags:
- { name: kernel.event_subscriber }

Sonata\AdminBundle\Templating\TemplateRegistry:
alias: 'sonata.admin.global_template_registry'

Smart\SonataBundle\Security\Handler\SmartSecurityHandler:
arguments:
- '@sonata.admin.security.handler.role'
- {name: yokai_enum.enum}

admin.batch_log:
class: Smart\SonataBundle\Admin\BatchLogAdmin
# Loader
smart_sonata.parameter_loader:
class: Smart\SonataBundle\Loader\ParameterLoader
public: true
arguments:
- ~
- Smart\SonataBundle\Entity\Log\BatchLog
- ~
tags:
- { name: sonata.admin, manager_type: orm, label: dashboard.label_batch_log }
- '@Doctrine\ORM\EntityManagerInterface'
Smart\SonataBundle\Loader\ParameterLoader:
public: false
alias: smart_sonata.parameter_loader

# Logger
smart_sonata.batch_logger:
class: Smart\SonataBundle\Logger\BatchLogger
public: true
arguments:
- '@Doctrine\ORM\EntityManagerInterface'
- '@Sentry\ClientInterface'

Smart\SonataBundle\Logger\BatchLogger:
public: false
alias: smart_sonata.batch_logger

smart_sonata.history_logger:
class: Smart\SonataBundle\Logger\HistoryLogger
public: true
arguments:
- '@Doctrine\ORM\EntityManagerInterface'

Smart\SonataBundle\Logger\HistoryLogger:
public: false
alias: smart_sonata.history_logger

Smart\SonataBundle\Config\IniOverrideConfig:
# Mailer
Smart\SonataBundle\Mailer\BaseMailer:
arguments:
- '%env(default::PLATFORM_BATCH_MEMORY)%'
- '@Symfony\Component\Mailer\MailerInterface'
- '@Smart\SonataBundle\Mailer\EmailProvider'
- '@Symfony\Contracts\Translation\TranslatorInterface'
- '@Smart\SonataBundle\Logger\HistoryLogger'
Smart\SonataBundle\Mailer\EmailProvider:
arguments:
- '@request_stack'

# The "Symfony\Component\DependencyInjection\ContainerInterface" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it.
# It's not a good way, but it's practical for the moment. It's used in AbstractAdmin::get. Need to replace all get call by injection
Symfony\Component\DependencyInjection\ContainerInterface: '@service_container'
# Provider
smart_sonata.parameter_provider:
class: Smart\SonataBundle\Provider\ParameterProvider
public: true
arguments:
- '@Doctrine\ORM\EntityManagerInterface'
Smart\SonataBundle\Provider\ParameterProvider:
public: false
alias: smart_sonata.parameter_provider

# Enum
Smart\SonataBundle\Enum\ParameterTypeEnum:
# Route
Smart\SonataBundle\Route\RouteLoader:
tags:
- {name: routing.loader}

# Security
security.processor.last_login:
class: Smart\SonataBundle\Security\Processor\LastLoginProcessor
arguments:
- '@doctrine.orm.entity_manager'
security.subscriber:
class: Smart\SonataBundle\Security\EventSubscriber\SecuritySubscriber
arguments:
- '@security.processor.last_login'
- '@translator'
tags:
- {name: yokai_enum.enum}
- { name: kernel.event_subscriber }
Smart\SonataBundle\Security\Handler\SmartSecurityHandler:
arguments:
- '@sonata.admin.security.handler.role'

# Templating
Sonata\AdminBundle\Templating\TemplateRegistry:
alias: 'sonata.admin.global_template_registry'
Loading

0 comments on commit addeff4

Please sign in to comment.