I've been stuck on this for the last two days. This helped a lot @Komiya 
Takeshi.

On Wednesday, November 21, 2018 at 6:01:59 PM UTC+1, Komiya Takeshi wrote:
>
> Hi, 
>
> I guess your goal is copying CSS files properly, not modifying config 
> object. Hence it is better to provide a way to copy them easily. 
> Is this right? 
>
> At present, you can do it with following code: 
>
> ``` 
> from sphinx.util.fileutil import copy_asset 
>
> def copy_asset_files(app, exc): 
>     asset_files = [...] 
>     if exc is None:  # build succeeded 
>         for path in asset_files: 
>             copy_asset(path, os.path.join(app.outdir, '_static')) 
>
> def setup(app): 
>     app.connect('build-finished', copy_asset_files) 
> ``` 
>
> I think this code is enough simple. What do you think? Would you like 
> to add another API to do that? 
>
> Thanks, 
> Takeshi KOMIYA 
> 2018年11月19日(月) 2:42 Vladimir Goncharov <[email protected] <javascript:>>: 
> > 
> > Hello! 
> > 
> > (This is a continuation of 
> https://github.com/sphinx-doc/sphinx/issues/1379) 
> > 
> > I'm developing an extension for drawing railroad diagrams in svg. So 
> there's a css file with default styles for diagrams which I'd like to see 
> included on every page that uses functionality of my plugin. I, however, 
> was not able to find any API for doing this. 
> > 
> > I'm looking for a solution that: 
> > 
> > will not require user to adjust 'html_static_path' in theirs conf.py. 
> That is, including my extension to the 'extensions' list should be enough 
> for it to work; 
> > will allow user to override the default stylesheet by providing their 
> own one; 
> > (optionally) will only include my css to the pages that actually use 
> directives from my plugin. 
> > 
> > Public API don't do what I want it to do: 
> > 
> > 'app.add_stylesheet' requires that "the filename must be relative to the 
> HTML static path, or a full URI with scheme". Naturally, none of my 
> extension's directory are on HTML static path, thus calling 
> 'app.add_stylesheet' is not enough by itself; 
> > modifying 'app.config.html_static_path' from the setup function of my 
> extension only works if user have not redefined 'html_static_path' in 
> theirs conf.py. This happens because variables from conf.py override 
> default config variables after all extensions re loaded; 
> > modifying 'app.config._raw_config['html_static_path']' does exactly what 
> I want, however, '_raw_config' is not part of the public API; 
> > modifying 'app.config.html_static_path' from 'builder-inited' hook seems 
> to work (that's how exhale does this) but Shimizukawa suggests that 
> extensions should not modify 'app.config'. 
> > 
> > So, there seem to be no way to add custom stylesheets and javascript 
> files from extensions properly. 
> > 
> > I propose either developing an official API for this or stating that 
> modifying 'app.config' from 'builder-inited' is fine (or maybe we should 
> use 'config-inited' for this?) and documenting this usage. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "sphinx-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sphinx-users. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/fb35f626-94ae-4c18-98ea-0c600d4aa6d8o%40googlegroups.com.

Reply via email to