code-lts / doctum

A php API documentation generator, fork of Sami
https://doctum.long-term.support/
MIT License
300 stars 32 forks source link

How to create a custom theme? #50

Closed iseries closed 1 year ago

iseries commented 2 years ago

Hello, after read the docs, i still don't get how to create my own custom theme. It is noticed that "a theme is just a directory with a manifest.yml". So i created a folder with a manifest.yml file in the documentRoot where doctum.phar and config.php is stored. When trying to build with doctum.phar update /path/to/config.php -v it outputs a message, that my custom theme could not found.

My question is: Where do I have to put the theme folder to be recognized?

Best, Rene

williamdes commented 2 years ago

Hello Rene, could you send the contents of the Manifest file? I think it may be because you are using a phar maybe you need to change the theme path to a full path Can you also send your config file?

iseries commented 2 years ago

Hi @williamdes ,

my config.php:

<?php

declare(strict_types = 1);

use Doctum\Doctum;
use Doctum\RemoteRepository\GitHubRemoteRepository;
use Doctum\Version\GitVersionCollection;
use Symfony\Component\Finder\Finder;

$iterator = Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('Resources')
    ->exclude('Tests')
    ->in($dir = '/usr/home/renerk/public_html/neosdoc/neos-development-collection');

return new Doctum($iterator, [
    'title' => 'Neos 8.2 API',
    'theme' => 'neos',
    'build_dir' => __DIR__ . '/build/neos/%version%',
    'cache_dir' => __DIR__ . '/cache/neos/%version%',
    'default_opened_level' => 2,
    ]
);

my manifest.yml:

name: neos
parent: default

My folder structure: image

Edit:

Tried to set the full path: image

williamdes commented 2 years ago

Hi @iseries I am sorry I did not manage to reply earlier, I think this is due to the fact you use a PHAR. If you use the composer version it should work without issues. I will keep this pinned down to see if I find a proper patch for this case

williamdes commented 1 year ago

Hi @iseries I found what you need to do, it's adding a template_dirs variable

return new Doctum($iterator, [
    'title' => 'Neos 8.2 API',
    'theme' => 'neos',
    'build_dir' => __DIR__ . '/build/neos/%version%',
    'cache_dir' => __DIR__ . '/cache/neos/%version%',
    'default_opened_level' => 2,
    // use a custom theme directory
    'template_dirs'        => [__DIR__ . '/neos'],
    ]
);