where should static media (pictures, html, pdf...) reside in Sphinx source project [duplicate] - 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

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.

How to output a custom static file in 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']

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

Install not adding all Content files

I have some xml files I want to distribute with the project. The Build Action is set to Content and the Copy to Output Directory is set to Copy always. When I publish, I see all the xml files in my content folder; however, when I install using ClickOnce, these files are missing. What am I missing?
The problem was in the project settings->Publish->Application Files... the xml files under Publish Status must be changed from Data File(Auto) to Include.

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