How to output a custom static file in Sphinx? - python-sphinx

Using Sphinx, one can include static files in the _static folder of the build output. How could I copy a static file to the root of the build folder?
Background: I'm hosting the output of a Sphinx project in Azure App Services, and because of a mp4 video in a few pages, I need a "web.config" file with the following entry:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
I need Sphinx to include the web.config in the root of the build folder.

Use html_extra_path. This is a configuration option that will copy the list of files given to the html build directory:
html_extra_path = ['path/to/web.config']

Related

WebAPI Core, set a custom nuget/packge folder

I am trying to figure out how to override the package folder from the user folder to a custom folder location like inside my project folder
I have a webapi Core project with an appSetting.json
I read a few posts and may suggests using nuget.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="globalPackagesFolder" value="d:\\packages" />
</config>
</configuration>
I added in my WebAPI project which show along side with appsetting.json.
When I build the project, I see no package folder.
I also read about packages.config but I can't find that file anywhere.
Any help is appreciated.
Thanks
The nuget.config file should be placed in a directory one level above the project and then it will work.
For an example, the ConsoleApp152 folder is the folder which contains all your project files. And nuget.config file should be placed at the one level above the project files.
When you finish it, please close VS and then restart your project to enable this setting. And it will act on all projects in the directory level where the current nuget.config file is located and also all projects in the subordinate directories.

where should static media (pictures, html, pdf...) reside in Sphinx source project [duplicate]

Using Sphinx, one can include static files in the _static folder of the build output. How could I copy a static file to the root of the build folder?
Background: I'm hosting the output of a Sphinx project in Azure App Services, and because of a mp4 video in a few pages, I need a "web.config" file with the following entry:
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
I need Sphinx to include the web.config in the root of the build folder.
Use html_extra_path. This is a configuration option that will copy the list of files given to the html build directory:
html_extra_path = ['path/to/web.config']

How to stop NuGet packaging from including unwanted files

I'm building a NuGet package with a folder hierarchy that looks like this:
ProjectDir
Infrastructure
class1.cs
class2.cs
Task
class3.cs
class3.cs
StuffToInclude
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
Project.nuspec
Note the nuspec file is generated simply with the "nuget spec" command, and then the following file section is added:
<files>
<file src="StuffToInclude\**\*.*" target="content" />
</files>
What I would expect (and want) is a content folder in the package that looks like this:
content
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
What I get however is a slightly larger content folder that includes a second copy of the "StuffToInclude" folder, looking like this:
content
StuffToInclude
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
Notice that the undesired StuffToInclude folder does not have the SampleCode subfolder in it -- somehow the nuget packer figured out that ".pp" files should not be placed in the content unless explicitly asked for. But all those other files (in all the other folders) are unnecessarily duplicated and it is not desirable to have them there - because when the package is consumed, that folder is also duplicated in the target project.
I thought perhaps something like this in the nuspec would help:
<files>
<file src="StuffToInclude\**\*.*" target="content" exclude="StuffToInclude\**\*.*"/>
</files>
but all variants I have tried for the "exclude" attribute don't seem to help.
How do I exclude the "StuffToInclude" file from being included in the content folder?
Many thanks.
How to stop NuGet packaging from including unwanted files
I assume the command you use when creating the package is something like nuget pack xx.csproj.
If so, what's the special reason you created a package based on project file after creating the .nuspec file?
According to this document, we can use nuget pack command based on the specified .nuspec or project file.
So usually, if we create a package based on .csproj, there's no need to create a .nuspec file. Also, if we want to create a package based on .nuspec, I suggest use command nuget pack xx.nuspec instead of nuget pack xx.csproj.
Cause of the issue:
I've done some tests and found when we put Project.nuspec file in project dir, and use a command like nuget pack xx.csproj,then the nuget.exe will read data from both xx.nuspec and xx.csproj, that's why you have a second copy.
1# Structure for nuget pack xx.csproj if no xx.nuspec in same directory:
content
StuffToInclude
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
2# Structure for nuget pack xx.nuspec:
content
SampleCode
sampleclass1.cs.pp
sampleclass2.cs.pp
Images
image1.gif
image2.gif
Doc
text1.txt
text2.txt
And when you use nuget pack command based on project file(.csproj) where exists a ProjectName.nuspec, it reads data from both .csproj and .nuspec. so it results in the second copy like what you got.
To resolve it:
Keep the xx.nuspec file and use command like nuget pack xx.nuspec.(suggested)
Delete the xx.nuspec file(Or delete the <Files> section) and use command like nuget pack xx.csproj, to include those xx.cs.pp files into content folder, you may need to set their build action to content.
Keep both the xx.nuspec file and the xx.csproj file (see below) and everything you want in the xx.nuspec file, but to avoid the unwanted second copies of things, make sure that every single item you don't want copied twice is set to a Build Action of None.

Access Qt resource files in VS 2017 with CMake

I am having trouble accessing qt resource files in a VS 2017 project with CMake. I was able to access the qrc files using Qt Creator. I have the following questions:
Where do I put the resource files? Preferably I would like to put resource files in the root directory. I have tried to put the files in the root director and in the directory they will be called.
What changes I should make to the CMakeLists.txt files?
How can I refer to the resource files? I have tried all the instruction I can find on internet. But none of them seem to work. For example I have tried: ":/prefix/filepath/filename" or ":prefix/filepath/filename".
Thanks a lot!
You can put your .qrc file where you want, for my project I make it on /res folder but is your choice. You can add your files on the resources edit manually the .qrc file as a normal xml file. Here a simple example:
<RCC>
<qresource prefix="/menu_img">
<file alias="cancel_img">icons/cancel-512.png</file>
<file alias="open_img">icons/folder-512.png</file>
<file alias="print_img">icons/printer-512.png</file>
</qresource>
</RCC>
In this resource files the images are inside the folder icons and the .qrc is outside.
After that your .qrc file is ready (assuming that you use qt5) you must add to your CMakeList.txt this line:
qt5_add_resources(PROJECT_RESOURCE path_to_rosource_file/resources.qrc)
then on your target you must add this rosource:
add_executable(
${TARGET_PROJECT}
${PROJECT_SOURCES}
${PROJECT_HEADERS}
${PROJECT_RESOURCES})
Now your resources is available inside your project as usual :/menu_img/cancel_img

VS2013 Publish does not copy content folder in referenced class library

I have the following folder structure:
Library <--[project ref]-- Web Project
-------- -----------
DataFiles
EngineFiles
.cs files .cs files
All files contined both folders have Build Action = Content & Copy To Output Directory = Copy Always. When I build the solution the files are getting created inside the respective folders of the /bin directory (DataFiles & EngineFiles folders).
When I publish locally the files also get created inside the respective folders in the /bin directory of my Web Project.
However when I try to publish via TFS the files flattened inside the /bin folder of my _PublishedWebsites, the DataFiles & EngineFiles folders no longer exist. I am using a custom build template that we have been using without any problems up to this point.
This is what the Target section of our build template looks like:
<Target Name="DropWebSiteUI">
<Message Text="Drop Web Site UI files" />
<CreateItem Include="$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\_PublishedWebsites\StackOverflow\**\*;">
<Output ItemName="WebSiteUI" TaskParameter="Include" />
</CreateItem>
<CreateItem Include="$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\en-US\*;">
<Output ItemName="ResourceFile_StackOverflowUI" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="#(WebSiteUI)" DestinationFiles="#(WebSiteUI->'$(DropLocation)\$(BuildNumber)\WebSiteUI\%(RecursiveDir)%(FileName)%(Extension)')" ContinueOnError="true" />
<Copy SourceFiles="#(ResourceFile_StackOverflowUI)" DestinationFiles="#(ResourceFile_StackOverlowUI->'$(DropLocation)\$(BuildNumber)\WebSiteUI\bin\en-US\%(FileName)%(Extension)')" />
</Target>
Any ideas as to why the folders are not getting copied over with the files included inside them?

Resources